Class: JSONP3::Token
- Inherits:
-
Object
- Object
- JSONP3::Token
- Defined in:
- lib/json_p3/token.rb
Overview
Tokens are produced by the lexer and consumed by the parser. Each token contains sub string from a JSONPath expression, its location within the JSONPath expression and a symbol indicating what type of token it is.
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#start ⇒ Object
readonly
Returns the value of attribute start.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(type, value, start, query, message: nil) ⇒ Token
constructor
A new instance of Token.
Constructor Details
#initialize(type, value, start, query, message: nil) ⇒ Token
Returns a new instance of Token.
13 14 15 16 17 18 19 |
# File 'lib/json_p3/token.rb', line 13 def initialize(type, value, start, query, message: nil) @type = type @value = value @start = start @query = query @message = end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
11 12 13 |
# File 'lib/json_p3/token.rb', line 11 def @message end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
11 12 13 |
# File 'lib/json_p3/token.rb', line 11 def query @query end |
#start ⇒ Object (readonly)
Returns the value of attribute start.
11 12 13 |
# File 'lib/json_p3/token.rb', line 11 def start @start end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
11 12 13 |
# File 'lib/json_p3/token.rb', line 11 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
11 12 13 |
# File 'lib/json_p3/token.rb', line 11 def value @value end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
21 22 23 24 25 26 27 28 |
# File 'lib/json_p3/token.rb', line 21 def ==(other) self.class == other.class && @type == other.type && @value == other.value && @start == other.start && @query == other.query && @message == other. end |
#hash ⇒ Object
32 33 34 |
# File 'lib/json_p3/token.rb', line 32 def hash [@type, @value].hash end |