Class: Splashy::Bucket

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

Overview

Private: Collector of elements.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

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

#countObject



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

Returns:

  • (Boolean)


21
22
23
# File 'lib/splashy/bucket.rb', line 21

def empty?
  self.count == 0
end