class NTable::ObjectAxis

An axis in which the labels are arbitrary objects. This axis cannot be serialized.

Attributes

Public Class Methods

new(labels_) click to toggle source

Create a ObjectAxis given an array of the label objects.

# File lib/ntable/axis.rb, line 255
def initialize(labels_)
  @a = labels_.dup
  @h = {}
  @a.each_with_index{ |n_, i_| @h[n_] = i_ }
  @size = labels_.size
end

Public Instance Methods

==(obj_) click to toggle source

See EmptyAxis#==

# File lib/ntable/axis.rb, line 269
def ==(obj_)
  obj_.is_a?(ObjectAxis) && @a == obj_.instance_variable_get(:@a)
end
eql?(obj_) click to toggle source

See NTable::EmptyAxis#eql?

# File lib/ntable/axis.rb, line 264
def eql?(obj_)
  obj_.is_a?(ObjectAxis) && @a.eql?(obj_.instance_variable_get(:@a))
end
from_json_object(json_obj_) click to toggle source

See NTable::EmptyAxis#from_json_object

# File lib/ntable/axis.rb, line 306
def from_json_object(json_obj_)
  raise "Unable to JSON serialize an ObjectAxis"
end
hash() click to toggle source

See NTable::EmptyAxis#hash

# File lib/ntable/axis.rb, line 274
def hash
  @a.hash
end
index(label_) click to toggle source

See NTable::EmptyAxis#index

# File lib/ntable/axis.rb, line 290
def index(label_)
  @h[label_]
end
inspect() click to toggle source

See NTable::EmptyAxis#inspect

# File lib/ntable/axis.rb, line 279
def inspect
  "#<#{self.class}:0x#{object_id.to_s(16)} #{@a.inspect}>"
end
Also aliased as: to_s
label(index_) click to toggle source

See NTable::EmptyAxis#label

# File lib/ntable/axis.rb, line 295
def label(index_)
  @a[index_]
end
to_json_object(json_obj_) click to toggle source

See NTable::EmptyAxis#to_json_object

# File lib/ntable/axis.rb, line 301
def to_json_object(json_obj_)
  raise "Unable to JSON serialize an ObjectAxis"
end
to_s() click to toggle source
Alias for: inspect