Class: Janeway::Token
- Inherits:
 - 
      Object
      
        
- Object
 - Janeway::Token
 
 
- Extended by:
 - Forwardable
 
- Defined in:
 - lib/janeway/token.rb
 
Overview
Tokens are produced by the lexer, they represent jsonpath query elements in a low-level, non-hierarchical way.
Instance Attribute Summary collapse
- 
  
    
      #lexeme  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute lexeme.
 - 
  
    
      #literal  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
write-access so ‘-’ operator can modify number value.
 - 
  
    
      #location  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute location.
 - 
  
    
      #type  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute type.
 
Instance Method Summary collapse
- #==(other) ⇒ Object
 - 
  
    
      #initialize(type, lexeme, literal, location)  ⇒ Token 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Token.
 - #to_s ⇒ Object
 
Constructor Details
#initialize(type, lexeme, literal, location) ⇒ Token
Returns a new instance of Token.
      17 18 19 20 21 22  | 
    
      # File 'lib/janeway/token.rb', line 17 def initialize(type, lexeme, literal, location) @type = type @lexeme = lexeme @literal = literal @location = location end  | 
  
Instance Attribute Details
#lexeme ⇒ Object (readonly)
Returns the value of attribute lexeme.
      10 11 12  | 
    
      # File 'lib/janeway/token.rb', line 10 def lexeme @lexeme end  | 
  
#literal ⇒ Object
write-access so ‘-’ operator can modify number value
      13 14 15  | 
    
      # File 'lib/janeway/token.rb', line 13 def literal @literal end  | 
  
#location ⇒ Object (readonly)
Returns the value of attribute location.
      10 11 12  | 
    
      # File 'lib/janeway/token.rb', line 10 def location @location end  | 
  
#type ⇒ Object (readonly)
Returns the value of attribute type.
      10 11 12  | 
    
      # File 'lib/janeway/token.rb', line 10 def type @type end  | 
  
Instance Method Details
#==(other) ⇒ Object
      28 29 30 31 32 33 34 35 36 37 38  | 
    
      # File 'lib/janeway/token.rb', line 28 def ==(other) # This is intended to make unit test expectations simple to define, experimental, may drop case other when Integer, String then @literal == other when Symbol then @type == other when Token @type == other.type && @lexeme == other.lexem && @literal = other.literal else raise ArgumentError, "don't know how to compare Token with #{other.inspect}" end end  | 
  
#to_s ⇒ Object
      24 25 26  | 
    
      # File 'lib/janeway/token.rb', line 24 def to_s "Token<#{@type}: #{@lexeme.inspect}>" end  |