Class: XmlUtils::Token

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

Constant Summary collapse

TYPES =
%i[
  start_tag end_tag empty_tag
  text cdata comment processing_instruction
  doctype xml_decl attribute_name attribute_value
  close_tag eq quote whitespace newline eof
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, value = nil, line = nil, position = nil) ⇒ Token

Returns a new instance of Token.



29
30
31
32
33
34
# File 'lib/xmlutils/tokenizer.rb', line 29

def initialize(type, value = nil, line = nil, position = nil)
  @type = type
  @value = value
  @line = line
  @position = position
end

Instance Attribute Details

#lineObject

Returns the value of attribute line.



20
21
22
# File 'lib/xmlutils/tokenizer.rb', line 20

def line
  @line
end

#positionObject

Returns the value of attribute position.



20
21
22
# File 'lib/xmlutils/tokenizer.rb', line 20

def position
  @position
end

#typeObject

Returns the value of attribute type.



20
21
22
# File 'lib/xmlutils/tokenizer.rb', line 20

def type
  @type
end

#valueObject

Returns the value of attribute value.



20
21
22
# File 'lib/xmlutils/tokenizer.rb', line 20

def value
  @value
end

Instance Method Details

#to_sObject



36
37
38
# File 'lib/xmlutils/tokenizer.rb', line 36

def to_s
  "<Token #{@type}: #{@value.inspect}>"
end