Class: Decode::Language::Ruby::Code

Inherits:
Object
  • Object
show all
Defined in:
lib/decode/language/ruby/code.rb

Overview

A Ruby-specific block of code.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#languageObject (readonly)

Returns the value of attribute language.



26
27
28
# File 'lib/decode/language/ruby/code.rb', line 26

def language
  @language
end

#textObject (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