Class: Decode::Language::Ruby::Code
- Inherits:
-
Object
- Object
- Decode::Language::Ruby::Code
- Defined in:
- lib/decode/language/ruby/code.rb
Overview
A Ruby-specific block of code.
Instance Attribute Summary collapse
-
#language ⇒ Object
readonly
Returns the value of attribute language.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
- #extract(into = []) ⇒ Object
-
#initialize(text, index, relative_to: nil, language: relative_to&.language) ⇒ Code
constructor
A new instance of Code.
Constructor Details
#initialize(text, index, relative_to: nil, language: relative_to&.language) ⇒ Code
Returns a new instance of Code.
16 17 18 19 20 21 22 |
# File 'lib/decode/language/ruby/code.rb', line 16 def initialize(text, index, relative_to: nil, language: relative_to&.language) @text = text @root = ::Parser::CurrentRuby.parse(text) @index = index @relative_to = relative_to @language = language end |
Instance Attribute Details
#language ⇒ Object (readonly)
Returns the value of attribute language.
26 27 28 |
# File 'lib/decode/language/ruby/code.rb', line 26 def language @language end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
24 25 26 |
# File 'lib/decode/language/ruby/code.rb', line 24 def text @text end |
Instance Method Details
#extract(into = []) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/decode/language/ruby/code.rb', line 28 def extract(into = []) if @index traverse(@root, into) end return into end |