Class: KQL::Accessor::Val

Inherits:
KQL::Accessor show all
Defined in:
lib/kql/accessor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(index) ⇒ Val

Returns a new instance of Val.



6
7
8
# File 'lib/kql/accessor.rb', line 6

def initialize(index)
  @index = index
end

Instance Attribute Details

#indexObject (readonly)

Returns the value of attribute index.



4
5
6
# File 'lib/kql/accessor.rb', line 4

def index
  @index
end

Instance Method Details

#==(other) ⇒ Object



18
19
20
21
22
# File 'lib/kql/accessor.rb', line 18

def ==(other)
  return false unless other.is_a?(Val)

  other.index == index
end

#execute(node) ⇒ Object



10
11
12
# File 'lib/kql/accessor.rb', line 10

def execute(node)
  node.arguments[index]
end

#match?(node) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/kql/accessor.rb', line 14

def match?(node)
  node.arguments.size > index
end