Class: KQL::Mapping

Inherits:
Query
  • Object
show all
Defined in:
lib/kql/mapping.rb

Instance Attribute Summary collapse

Attributes inherited from Query

#alternatives

Instance Method Summary collapse

Constructor Details

#initialize(alternatives, mapping) ⇒ Mapping

Returns a new instance of Mapping.



7
8
9
10
# File 'lib/kql/mapping.rb', line 7

def initialize(alternatives, mapping)
  super(alternatives)
  @mapping = mapping
end

Instance Attribute Details

#mappingObject

Returns the value of attribute mapping.



5
6
7
# File 'lib/kql/mapping.rb', line 5

def mapping
  @mapping
end

Instance Method Details

#==(other) ⇒ Object



17
18
19
20
21
# File 'lib/kql/mapping.rb', line 17

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

  super(other) && other.mapping = mapping
end

#execute(document) ⇒ Object



12
13
14
15
# File 'lib/kql/mapping.rb', line 12

def execute(document)
  nodes = super
  nodes.map { |node| mapping.execute(node) }
end