Class: Decode::Language::Ruby::Block
- Inherits:
-
Definition
- Object
- Definition
- Decode::Language::Ruby::Block
- 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
-
#container? ⇒ Boolean
A block can sometimes be a container for other definitions.
- #convert(kind) ⇒ Object
-
#long_form ⇒ Object
The long form of the block.
- #nested_name ⇒ Object
-
#qualified_form ⇒ Object
The fully qualified name of the block.
-
#short_form ⇒ Object
The short form of the block.
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.
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_form ⇒ Object
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_name ⇒ Object
18 19 20 |
# File 'lib/decode/language/ruby/block.rb', line 18 def nested_name ".#{name}" end |
#qualified_form ⇒ Object
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_form ⇒ Object
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 |