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, #inspect, #location, #multiline?, #nested?, #path, #path_name, #qualified_name, #start_with?, #text

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)


14
15
16
# File 'lib/decode/language/ruby/block.rb', line 14

def container?
	true
end

#convert(kind) ⇒ Object



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

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



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

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



18
19
20
# File 'lib/decode/language/ruby/block.rb', line 18

def nested_name
	".#{name}"
end

#qualified_formObject

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



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

def qualified_form
	self.qualified_name
end

#short_formObject

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



24
25
26
# File 'lib/decode/language/ruby/block.rb', line 24

def short_form
	@name.to_s
end