Class: Decode::Language::Ruby::Method

Inherits:
Definition
  • Object
show all
Defined in:
lib/decode/language/ruby/method.rb

Overview

A Ruby-specific method.

Direct Known Subclasses

Function

Instance Attribute Summary

Attributes inherited from Definition

#comments, #language, #name, #parent

Instance Method Summary collapse

Methods inherited from Definition

#container?, #documentation, #initialize, #inspect, #location, #multiline?, #nested?, #nested_name, #path, #path_name, #qualified_name, #start_with?, #text

Constructor Details

This class inherits a constructor from Decode::Definition

Instance Method Details

#arguments_nodeObject

The node which contains the function arguments.



20
21
22
23
24
25
26
# File 'lib/decode/language/ruby/method.rb', line 20

def arguments_node
	if node = @node.children[1]
		if node.location.expression
			return node
		end
	end
end

#convert(kind) ⇒ Object



46
47
48
49
50
51
52
53
54
55
# File 'lib/decode/language/ruby/method.rb', line 46

def convert(kind)
	case kind
	when :attribute
		Attribute.new(@node, @name,
			comments: @comments, parent: @parent, language: @language
		)
	else
		super
	end
end

#long_formObject

The long form of the method. e.g. ‘def puts(*lines, separator: “n”)`.



30
31
32
33
34
35
36
37
38
# File 'lib/decode/language/ruby/method.rb', line 30

def long_form
	if arguments_node = self.arguments_node
		@node.location.keyword.join(
			arguments_node.location.expression
		).source
	else
		self.short_form
	end
end

#qualified_formObject

The fully qualified name of the block. e.g. ‘::Barnyard#foo`.



42
43
44
# File 'lib/decode/language/ruby/method.rb', line 42

def qualified_form
	self.qualified_name
end

#short_formObject

The short form of the method. e.g. ‘def puts`.



15
16
17
# File 'lib/decode/language/ruby/method.rb', line 15

def short_form
	@node.location.keyword.join(@node.location.name).source
end