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.



31
32
33
34
35
36
37
# File 'lib/decode/language/ruby/code.rb', line 31

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.



41
42
43
# File 'lib/decode/language/ruby/code.rb', line 41

def language
  @language
end

#textObject (readonly)

Returns the value of attribute text.



39
40
41
# File 'lib/decode/language/ruby/code.rb', line 39

def text
  @text
end

Instance Method Details

#extract(into = []) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/decode/language/ruby/code.rb', line 43

def extract(into = [])
	if @index
		traverse(@root, into)
	end
	
	return into
end