Class: Splashy::Bucket
- Inherits:
-
Object
- Object
- Splashy::Bucket
- Defined in:
- lib/splashy/bucket.rb
Overview
Private: Collector of elements.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #<<(element) ⇒ Object
- #count ⇒ Object
- #elements(count) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(name) ⇒ Bucket
constructor
A new instance of Bucket.
Constructor Details
#initialize(name) ⇒ Bucket
Returns a new instance of Bucket.
8 9 10 11 |
# File 'lib/splashy/bucket.rb', line 8 def initialize( name ) @name = name @elements = [] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/splashy/bucket.rb', line 6 def name @name end |
Instance Method Details
#<<(element) ⇒ Object
13 14 15 |
# File 'lib/splashy/bucket.rb', line 13 def <<( element ) @elements << element end |
#count ⇒ Object
25 26 27 |
# File 'lib/splashy/bucket.rb', line 25 def count @elements.count end |
#elements(count) ⇒ Object
17 18 19 |
# File 'lib/splashy/bucket.rb', line 17 def elements( count ) @elements[0, count] end |
#empty? ⇒ Boolean
21 22 23 |
# File 'lib/splashy/bucket.rb', line 21 def empty? self.count == 0 end |