Class: DataSet::Label
- Inherits:
-
Object
- Object
- DataSet::Label
- Defined in:
- lib/tukey/data_set/label.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#meta ⇒ Object
Returns the value of attribute meta.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#==(other) ⇒ Object
is used for comparison of two instances directly.
- #deep_dup ⇒ Object
-
#eql?(other) ⇒ Boolean
eql? and hash are both used for comparisons when you call ‘.uniq` on an array of labels.
- #hash ⇒ Object
-
#initialize(name, id: nil, meta: {}) ⇒ Label
constructor
A new instance of Label.
Constructor Details
#initialize(name, id: nil, meta: {}) ⇒ Label
Returns a new instance of Label.
9 10 11 12 13 14 |
# File 'lib/tukey/data_set/label.rb', line 9 def initialize(name, id: nil, meta: {}) @name = name @id = id || name fail ArgumentError, 'DataSet::Label meta must be a Hash' unless .is_a?(Hash) @meta = OpenStruct.new() end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/tukey/data_set/label.rb', line 5 def id @id end |
#meta ⇒ Object
Returns the value of attribute meta.
7 8 9 |
# File 'lib/tukey/data_set/label.rb', line 7 def @meta end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/tukey/data_set/label.rb', line 6 def name @name end |
Instance Method Details
#==(other) ⇒ Object
is used for comparison of two instances directly
17 18 19 |
# File 'lib/tukey/data_set/label.rb', line 17 def ==(other) other.id == id end |
#deep_dup ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/tukey/data_set/label.rb', line 31 def deep_dup label = dup id = id.dup if id name = name.dup if name = .dup if label end |
#eql?(other) ⇒ Boolean
eql? and hash are both used for comparisons when you call ‘.uniq` on an array of labels.
23 24 25 |
# File 'lib/tukey/data_set/label.rb', line 23 def eql?(other) self == other end |
#hash ⇒ Object
27 28 29 |
# File 'lib/tukey/data_set/label.rb', line 27 def hash id.hash end |