Module: Siren::JsonQuery::SliceAccess

Defined in:
lib/siren/json_query_nodes.rb

Instance Method Summary collapse

Instance Method Details

#value(object, root, symbols, current = nil) ⇒ Object



40
41
42
43
44
45
46
47
48
49
# File 'lib/siren/json_query_nodes.rb', line 40

def value(object, root, symbols, current = nil)
  a, b = *[head, tail].map { |x| x.value(root, symbols, current) }
  s = step.respond_to?(:number) ? step.number.value(root, symbols, current) : 1
  result = []
  while a <= b
    result << object[a]
    a += s
  end
  result
end