Class: XfOOrth::Token
Overview
A class used to hold vital info extracted from the source code.
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
The code fragment in this token.
Instance Method Summary collapse
-
#add(text, tags = nil) ⇒ Object
Append some text/tags to the code_fragment.
-
#has_tag?(value) ⇒ Boolean
Does this token have the specified tag?.
-
#initialize ⇒ Token
constructor
Set up an empty token.
-
#to_s ⇒ Object
As a string for debugging.
Constructor Details
#initialize ⇒ Token
Set up an empty token
13 14 15 16 |
# File 'lib/fOOrth/compiler/token.rb', line 13 def initialize @code = '' @tags = [] end |
Instance Attribute Details
#code ⇒ Object (readonly)
The code fragment in this token.
10 11 12 |
# File 'lib/fOOrth/compiler/token.rb', line 10 def code @code end |
Instance Method Details
#add(text, tags = nil) ⇒ Object
Append some text/tags to the code_fragment.
19 20 21 22 23 |
# File 'lib/fOOrth/compiler/token.rb', line 19 def add(text, =nil) @code << text @tags.concat().uniq! if self end |
#has_tag?(value) ⇒ Boolean
Does this token have the specified tag?
26 27 28 |
# File 'lib/fOOrth/compiler/token.rb', line 26 def has_tag?(value) @tags.include?(value) end |
#to_s ⇒ Object
As a string for debugging.
31 32 33 |
# File 'lib/fOOrth/compiler/token.rb', line 31 def to_s "Tags=#{@tags.inspect} Code=#{@code.inspect}" end |