class NTable::Structure::Position

A coordinate into a table. This object is often provided during iteration to indicate where you are in the iteration. You should not need to create a Position object yourself.

Public Instance Methods

==(obj_) click to toggle source
Alias for: eql?
[](axis_) click to toggle source
Alias for: coord
coord(axis_) click to toggle source

Returns the label of the coordinate along the given axis. The axis may be provided by name or index.

# File lib/ntable/structure.rb, line 218
def coord(axis_)
  ainfo_ = @structure.axis(axis_)
  ainfo_ ? _coords[ainfo_.axis_index] : nil
end
Also aliased as: []
coord_array() click to toggle source

Returns an array of all coordinate labels along the axes in order.

# File lib/ntable/structure.rb, line 228
def coord_array
  _coords.dup
end
eql?(obj_) click to toggle source

Standard equality check

# File lib/ntable/structure.rb, line 199
def eql?(obj_)
  obj_.is_a?(Position) && obj_.structure.eql?(@structure) && obj_._offset.eql?(self._offset)
end
Also aliased as: ==
hash() click to toggle source

Standard hash value

# File lib/ntable/structure.rb, line 207
def hash
  @structure.hash + @vector.hash
end
inspect() click to toggle source

Basic output.

# File lib/ntable/structure.rb, line 191
def inspect
  "#<#{self.class}:0x#{object_id.to_s(16)} #{coord_array.inspect}>"
end
Also aliased as: to_s
next() click to toggle source

Returns the Position of the “next” cell in the table, or nil if this is the last cell.

# File lib/ntable/structure.rb, line 236
def next
  v_ = @vector.dup
  @structure._inc_vector(v_) ? nil : Position.new(@structure, v_)
end
prev() click to toggle source

Returns the Position of the “previous” cell in the table, or nil if this is the first cell.

# File lib/ntable/structure.rb, line 245
def prev
  v_ = @vector.dup
  @structure._dec_vector(v_) ? nil : Position.new(@structure, v_)
end
to_s() click to toggle source
Alias for: inspect