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
#The comment lines which directly preceeded the definition., #The language the symbol is defined within., #The path to the definition, relative to the parent., #The source file containing this definition., #comments, #language, #parent, #path, #source, #visibility
Instance Method Summary collapse
-
#container? ⇒ Boolean
A block can sometimes be a container for other definitions.
-
#convert(kind) ⇒ Object
Convert the block to a different kind of definition.
-
#long_form ⇒ Object
The long form of the block.
-
#nested_name ⇒ Object
Generate a nested name for the block.
-
#qualified_form ⇒ Object
The fully qualified name of the block.
-
#short_form ⇒ Object
The short form of the block.
Methods inherited from Definition
#:public, :private, :protected=, #The parent definition, defining lexical scope.=, #The symbol name e.g. `:Decode`.=, #coverage_relevant?, #documentation, #documented?, #full_path, #initialize, #inspect, #location, #multiline?, #name, #nested?, #public?, #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
Convert the block to a different kind of definition.
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/decode/language/ruby/block.rb', line 47 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)`.
31 32 33 34 35 36 37 |
# File 'lib/decode/language/ruby/block.rb', line 31 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
Generate a nested name for the block.
19 20 21 |
# File 'lib/decode/language/ruby/block.rb', line 19 def nested_name ".#{name}" end |
#qualified_form ⇒ Object
The fully qualified name of the block. e.g. ‘::Barnyard::foo`.
41 42 43 |
# File 'lib/decode/language/ruby/block.rb', line 41 def qualified_form self.qualified_name end |
#short_form ⇒ Object
The short form of the block. e.g. ‘foo`.
25 26 27 |
# File 'lib/decode/language/ruby/block.rb', line 25 def short_form @name.to_s end |