Class: JMESPath::TokenStream Private

Inherits:
Object
  • Object
show all
Defined in:
lib/jmespath/token_stream.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expression, tokens) ⇒ TokenStream

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of TokenStream.

Parameters:



7
8
9
10
11
12
13
# File 'lib/jmespath/token_stream.rb', line 7

def initialize(expression, tokens)
  @expression = expression
  @tokens = tokens
  @token = nil
  @position = -1
  self.next
end

Instance Attribute Details

#expressionString<JMESPath> (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:



16
17
18
# File 'lib/jmespath/token_stream.rb', line 16

def expression
  @expression
end

#positionInteger (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Integer)


22
23
24
# File 'lib/jmespath/token_stream.rb', line 22

def position
  @position
end

#tokenToken (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:



19
20
21
# File 'lib/jmespath/token_stream.rb', line 19

def token
  @token
end

Instance Method Details

#inspectObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



35
36
37
38
39
40
41
42
# File 'lib/jmespath/token_stream.rb', line 35

def inspect
  str = []
  @tokens.each do |token|
    str << "%3d  %-15s %s" %
     [token.position, token.type, token.value.inspect]
  end
  str.join("\n")
end

#lookahead(count) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



30
31
32
# File 'lib/jmespath/token_stream.rb', line 30

def lookahead(count)
  @tokens[@position + count] || Token::NULL_TOKEN
end

#next(options = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :match (Array<Symbol>)

    Requires the next token to be one of the given symbols or an error is raised.



26
27
28
# File 'lib/jmespath/token_stream.rb', line 26

def next(options = {})
  validate_match(_next, options[:match])
end