Class: Decode::Language::Ruby::Block

Inherits:
Definition show all
Defined in:
lib/decode/language/ruby/block.rb

Overview

A Ruby-specific block which might carry other definitions.

Instance Attribute Summary

Attributes inherited from Definition

#comments, #language, #name, #parent

Instance Method Summary collapse

Methods inherited from Definition

#documentation, #initialize, #multiline?, #nested?, #path, #qualified_name, #start_with?, #text, #to_s

Constructor Details

This class inherits a constructor from Decode::Definition

Instance Method Details

#container?Boolean

A block can sometimes be a container for other definitions.

Returns:

  • (Boolean)


29
30
31
# File 'lib/decode/language/ruby/block.rb', line 29

def container?
	true
end

#convert(kind) ⇒ Object



59
60
61
62
63
64
65
66
67
68
# File 'lib/decode/language/ruby/block.rb', line 59

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 block. e.g. ‘foo(:bar)`.



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

def long_form
	if @node.location.line == @node.location.last_line
		@node.location.expression.source
	else
		@node.children[0].location.expression.source
	end
end

#nested_nameObject



33
34
35
# File 'lib/decode/language/ruby/block.rb', line 33

def nested_name
	".#{name}"
end

#qualified_formObject

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



55
56
57
# File 'lib/decode/language/ruby/block.rb', line 55

def qualified_form
	self.qualified_name
end

#short_formObject

The short form of the block. e.g. ‘foo`.



39
40
41
# File 'lib/decode/language/ruby/block.rb', line 39

def short_form
	@name.to_s
end