class DDQL::Token
Attributes
data[R]
location[RW]
type[R]
Public Class Methods
new(data:, location: nil, type:)
click to toggle source
# File lib/ddql/token.rb, line 10 def initialize(data:, location: nil, type:) @data = data @location = location @type = type end
Public Instance Methods
and?()
click to toggle source
# File lib/ddql/token.rb, line 16 def and? data == 'AND' end
as_hash()
click to toggle source
# File lib/ddql/token.rb, line 20 def as_hash type.as_hash(data) end
comparison?()
click to toggle source
# File lib/ddql/token.rb, line 24 def comparison? type.comparison?(data) end
complex_comparison?()
click to toggle source
# File lib/ddql/token.rb, line 28 def complex_comparison? type.complex_comparison?(data) end
infix?()
click to toggle source
# File lib/ddql/token.rb, line 32 def infix? type.infix? end
math?()
click to toggle source
# File lib/ddql/token.rb, line 36 def math? type.math?(data) end
op_data()
click to toggle source
# File lib/ddql/token.rb, line 40 def op_data data.squish end
or?()
click to toggle source
# File lib/ddql/token.rb, line 44 def or? data == 'OR' end
parse(parser, expression: nil)
click to toggle source
# File lib/ddql/token.rb, line 48 def parse(parser, expression: nil) type.parse(parser, self, expression: expression) end
post_process(parser:, expression:)
click to toggle source
# File lib/ddql/token.rb, line 52 def post_process(parser:, expression:) raise "#{type} doesn't support post-processing" unless supports_post_processing? type.post_process(parser: parser, expression: expression) end
postfix?()
click to toggle source
# File lib/ddql/token.rb, line 57 def postfix? type.postfix? end
prefix?()
click to toggle source
# File lib/ddql/token.rb, line 61 def prefix? type.prefix? end
simple_comparison?()
click to toggle source
# File lib/ddql/token.rb, line 65 def simple_comparison? type.simple_comparison?(data) end
supports_post_processing?()
click to toggle source
# File lib/ddql/token.rb, line 69 def supports_post_processing? type.supports_post_processing? end
to_h()
click to toggle source
# File lib/ddql/token.rb, line 73 def to_h type.as_hash(data) end
to_s()
click to toggle source
# File lib/ddql/token.rb, line 77 def to_s "#{type.name} : #{data}" end
type?(token_type)
click to toggle source
# File lib/ddql/token.rb, line 81 def type?(token_type) token_type == type end