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, #multiline?, #nested?, #nested_name, #path, #qualified_name, #start_with?, #text, #to_s

Constructor Details

This class inherits a constructor from Decode::Definition

Instance Method Details

#arguments_nodeObject

The node which contains the function arguments.



35
36
37
38
39
40
41
# File 'lib/decode/language/ruby/method.rb', line 35

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

#convert(kind) ⇒ Object



61
62
63
64
65
66
67
68
69
70
# File 'lib/decode/language/ruby/method.rb', line 61

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”)`.



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

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`.



57
58
59
# File 'lib/decode/language/ruby/method.rb', line 57

def qualified_form
	self.qualified_name
end

#short_formObject

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



30
31
32
# File 'lib/decode/language/ruby/method.rb', line 30

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