Class: NTable::EmptyAxis

Inherits:
Object
  • Object
show all
Defined in:
lib/ntable/axis.rb

Overview

This is a “null” axis that has no elements. Not terribly useful by itself, but may be a reasonable base class. Accordingly, we will use this class to document the methods required for an axis object.

In general, an axis describes a particular dimension in the table: how large the table is in that dimension, and how the ordered “rows” along that dimension are named.

Instance Method Summary collapse

Instance Method Details

#eql?(obj_) ⇒ Boolean Also known as: ==

Axis objects must implement an equality check.

Returns:

  • (Boolean)


54
55
56
# File 'lib/ntable/axis.rb', line 54

def eql?(obj_)
  obj_.is_a?(EmptyAxis)
end

#from_json_object(json_obj_) ⇒ Object

Configure this axis given a hash configuration that came from a JSON serialization.



110
111
# File 'lib/ntable/axis.rb', line 110

def from_json_object(json_obj_)
end

#hashObject

Axis objects must implement a hash



62
63
64
# File 'lib/ntable/axis.rb', line 62

def hash
  self.class.hash
end

#index(label_) ⇒ Object

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



86
87
88
# File 'lib/ntable/axis.rb', line 86

def index(label_)
  nil
end

#inspectObject Also known as: to_s

Axis methods should implement display methods for debugging.



69
70
71
# File 'lib/ntable/axis.rb', line 69

def inspect
  "#<#{self.class}:0x#{object_id.to_s(16)}>"
end

#label(index_) ⇒ Object

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



95
96
97
# File 'lib/ntable/axis.rb', line 95

def label(index_)
  nil
end

#sizeObject

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



78
79
80
# File 'lib/ntable/axis.rb', line 78

def size
  0
end

#to_json_object(json_obj_) ⇒ Object

Populate the given hash with the configuration of this axis. The hash will eventually be serialized via JSON.



103
104
# File 'lib/ntable/axis.rb', line 103

def to_json_object(json_obj_)
end