Class: Speck::Battery
- Inherits:
-
Object
- Object
- Speck::Battery
- Defined in:
- lib/speck/battery.rb
Overview
A Battery of Specks is a set of specks which should be executed
together, and which interdepend upon other Specks in the battery.
Batteries are recursive structures; that is, a Battery may have sub–
Batteries for relevant objects.
Instance Attribute Summary collapse
-
#specks ⇒ Object
readonly
Returns the value of attribute specks.
-
#targets ⇒ Object
readonly
Returns the value of attribute targets.
Instance Method Summary collapse
- #<<(speck) ⇒ Object
- #[](object) ⇒ Object
-
#initialize ⇒ Battery
constructor
A new instance of Battery.
Constructor Details
#initialize ⇒ Battery
Returns a new instance of Battery.
12 13 14 15 |
# File 'lib/speck/battery.rb', line 12 def initialize @specks = Array.new @targets = Hash.new end |
Instance Attribute Details
#specks ⇒ Object (readonly)
Returns the value of attribute specks.
9 10 11 |
# File 'lib/speck/battery.rb', line 9 def specks @specks end |
#targets ⇒ Object (readonly)
Returns the value of attribute targets.
10 11 12 |
# File 'lib/speck/battery.rb', line 10 def targets @targets end |
Instance Method Details
#<<(speck) ⇒ Object
17 18 19 20 21 |
# File 'lib/speck/battery.rb', line 17 def << speck @specks << speck @targets[speck.target] ||= Battery.new return self end |
#[](object) ⇒ Object
23 24 25 |
# File 'lib/speck/battery.rb', line 23 def [] object return @targets[object] end |