Class: JMESPath::Nodes::SimpleSlice Private

Inherits:
Slice
  • Object
show all
Defined in:
lib/jmespath/nodes/slice.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 Method Summary collapse

Methods inherited from Slice

#optimize

Methods inherited from Node

#chains_with?, #optimize

Constructor Details

#initialize(start, stop) ⇒ SimpleSlice

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 SimpleSlice.



75
76
77
# File 'lib/jmespath/nodes/slice.rb', line 75

def initialize(start, stop)
  super(start, stop, 1)
end

Instance Method Details

#visit(value) ⇒ 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.



79
80
81
82
83
# File 'lib/jmespath/nodes/slice.rb', line 79

def visit(value)
  if (value = value.respond_to?(:to_str) ? value.to_str : value.respond_to?(:to_ary) ? value.to_ary : nil)
    value[@start, @stop - @start]
  end
end