Class: Histogram::EquivalenceClass

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#idObject (readonly)

Returns the value of attribute id.



11
12
13
# File 'lib/histogram.rb', line 11

def id
  @id
end

#valuesObject (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

Returns:

  • (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

#sizeObject Also known as: count



37
38
39
# File 'lib/histogram.rb', line 37

def size
  @values.size
end