Class: Histogram::EquivalenceClass
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
- #<<(anObject) ⇒ Object
- #each(&block) ⇒ Object
- #include?(anObject) ⇒ Boolean
-
#initialize(id, *values) ⇒ EquivalenceClass
constructor
A new instance of EquivalenceClass.
- #size ⇒ Object (also: #count)
Constructor Details
#initialize(id, *values) ⇒ EquivalenceClass
Returns a new instance of EquivalenceClass.
13 14 15 16 |
# File 'lib/histogram.rb', line 13 def initialize ( id, *values ) @id = id @values = values.flatten end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
11 12 13 |
# File 'lib/histogram.rb', line 11 def id @id end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
11 12 13 |
# File 'lib/histogram.rb', line 11 def values @values end |
Instance Method Details
#<<(anObject) ⇒ Object
32 33 34 |
# File 'lib/histogram.rb', line 32 def << ( anObject ) @values << anObject end |
#each(&block) ⇒ Object
27 28 29 |
# File 'lib/histogram.rb', line 27 def each ( &block ) @values.each(&block) end |
#include?(anObject) ⇒ Boolean
19 20 21 22 23 24 |
# File 'lib/histogram.rb', line 19 def include? ( anObject ) if @values.empty? raise "You cannot call #{self.class}#include? with an empty class" end anObject == @values.first end |
#size ⇒ Object Also known as: count
37 38 39 |
# File 'lib/histogram.rb', line 37 def size @values.size end |