Class: KQL::Tokenizer::Token
- Inherits:
-
Object
- Object
- KQL::Tokenizer::Token
- Defined in:
- lib/kql/tokenizer.rb
Instance Attribute Summary collapse
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(type, value, line, column) ⇒ Token
constructor
A new instance of Token.
- #to_s ⇒ Object (also: #inspect)
Constructor Details
#initialize(type, value, line, column) ⇒ Token
Returns a new instance of Token.
12 13 14 15 16 17 |
# File 'lib/kql/tokenizer.rb', line 12 def initialize(type, value, line, column) @type = type @value = value @line = line @column = column end |
Instance Attribute Details
#column ⇒ Object (readonly)
Returns the value of attribute column.
10 11 12 |
# File 'lib/kql/tokenizer.rb', line 10 def column @column end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
10 11 12 |
# File 'lib/kql/tokenizer.rb', line 10 def line @line end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
10 11 12 |
# File 'lib/kql/tokenizer.rb', line 10 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
10 11 12 |
# File 'lib/kql/tokenizer.rb', line 10 def value @value end |
Instance Method Details
#==(other) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/kql/tokenizer.rb', line 19 def ==(other ) return false unless other.is_a?(Token) return false unless type == other.type && value == other.value if line && other.line return false unless line == other.line end if column && other.column return false unless column == other.column end true end |
#to_s ⇒ Object Also known as: inspect
33 34 35 |
# File 'lib/kql/tokenizer.rb', line 33 def to_s "#{value.inspect} (#{line || '?'}:#{column || '?'})" end |