Class: Accumulators::Count
- Inherits:
-
Object
- Object
- Accumulators::Count
- Defined in:
- lib/accumulators/count.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
Instance Method Summary collapse
- #add(rhs) ⇒ Object
-
#initialize ⇒ Count
constructor
A new instance of Count.
Constructor Details
#initialize ⇒ Count
Returns a new instance of Count.
5 6 7 |
# File 'lib/accumulators/count.rb', line 5 def initialize @count = 0 end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
3 4 5 |
# File 'lib/accumulators/count.rb', line 3 def count @count end |
Instance Method Details
#add(rhs) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/accumulators/count.rb', line 9 def add(rhs) if rhs.is_a? Accumulators::Count @count += rhs.count else @count += 1 end end |