Class: Gammo::Tokenizer::BaseToken
- Inherits:
-
Object
- Object
- Gammo::Tokenizer::BaseToken
- Defined in:
- lib/gammo/tokenizer/tokens.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#data ⇒ Object
Returns the value of attribute data.
-
#tag ⇒ Object
Returns the value of attribute tag.
Instance Method Summary collapse
- #concat(s) ⇒ Object
-
#initialize(data = '', attributes: [], tag: nil) ⇒ BaseToken
constructor
A new instance of BaseToken.
- #to_s ⇒ Object
Constructor Details
#initialize(data = '', attributes: [], tag: nil) ⇒ BaseToken
Returns a new instance of BaseToken.
8 9 10 11 12 |
# File 'lib/gammo/tokenizer/tokens.rb', line 8 def initialize(data = '', attributes: [], tag: nil) @data = data @attributes = attributes @tag = tag end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
6 7 8 |
# File 'lib/gammo/tokenizer/tokens.rb', line 6 def attributes @attributes end |
#data ⇒ Object
Returns the value of attribute data.
6 7 8 |
# File 'lib/gammo/tokenizer/tokens.rb', line 6 def data @data end |
#tag ⇒ Object
Returns the value of attribute tag.
6 7 8 |
# File 'lib/gammo/tokenizer/tokens.rb', line 6 def tag @tag end |
Instance Method Details
#concat(s) ⇒ Object
14 15 16 |
# File 'lib/gammo/tokenizer/tokens.rb', line 14 def concat(s) data << s end |
#to_s ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/gammo/tokenizer/tokens.rb', line 18 def to_s s = "<#{self.class}" members = [] members << "tag=\"#{tag}\"" if tag members << "data=\"#{data}\"" if data members << "attributes=\"#{attributes}\"" if attributes && !attributes.empty? "<#{self.class} #{members.join(' ')}>" end |