class NTable::Structure::AxisInfo

A data structure that provides information about a particular axis/dimension in a Structure. It provides access to the axis object, as well as the axis’s name (if any) and 0-based index into the list of axes. You should never need to create an AxisInfo yourself, but you can obtain one from NTable::Structure#axis.

Attributes

axis_index[R]

The 0-based index of this axis in the structure. i.e. the first, most major axis has number 0.

axis_name[R]

The name of this axis in the structure as a string, or nil for no name.

axis_object[R]

The underlying axis implementation

Public Instance Methods

==(obj_) click to toggle source
Alias for: eql?
[](index_) click to toggle source
Alias for: label
each() { |label| ... } click to toggle source

Iterate over the labels, in order.

# File lib/ntable/structure.rb, line 128
def each
  if block_given?
    @axis_object.size.times do |i_|
      yield @axis_object.label(i_)
    end
  else
    to_enum
  end
end
eql?(obj_) click to toggle source

Standard equality check

# File lib/ntable/structure.rb, line 143
def eql?(obj_)
  obj_.is_a?(AxisInfo) && @axis_object.eql?(obj_.axis_object) && @axis_name.eql?(obj_.axis_name)
end
Also aliased as: ==
index(label_) click to toggle source

Given a label object, return the corresponding 0-based integer index. Returns nil if the label is not recognized.

# File lib/ntable/structure.rb, line 103
def index(label_)
  @axis_object.index(label_)
end
inspect() click to toggle source

Basic output.

# File lib/ntable/structure.rb, line 80
def inspect
  "#<#{self.class}:0x#{object_id.to_s(16)} #{@axis_name}:#{@axis_object.class.name.sub('NTable::', '')}>"
end
Also aliased as: to_s
label(index_) click to toggle source

Given a 0-based integer index, return the corresponding label object. Returns nil if the index is out of bounds (i.e. is less than 0 or greater than or equal to size.)

# File lib/ntable/structure.rb, line 112
def label(index_)
  @axis_object.label(index_)
end
Also aliased as: []
size() click to toggle source

Return the number of rows along this axis. An empty axis will return 0.

# File lib/ntable/structure.rb, line 121
def size
  @axis_object.size
end
to_s() click to toggle source
Alias for: inspect