Class: Gammo::Tokenizer::BaseToken

Inherits:
Object
  • Object
show all
Defined in:
lib/gammo/tokenizer/tokens.rb

Direct Known Subclasses

EscapedToken

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#attributesObject

Returns the value of attribute attributes.



6
7
8
# File 'lib/gammo/tokenizer/tokens.rb', line 6

def attributes
  @attributes
end

#dataObject

Returns the value of attribute data.



6
7
8
# File 'lib/gammo/tokenizer/tokens.rb', line 6

def data
  @data
end

#tagObject

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_sObject



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