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, #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.
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 :attr 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)`.
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_name ⇒ Object
33 34 35 |
# File 'lib/decode/language/ruby/block.rb', line 33 def nested_name ".#{name}" end |
#qualified_form ⇒ Object
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_form ⇒ Object
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 |