Class: Construqt::Racks::Rack
- Inherits:
-
Object
- Object
- Construqt::Racks::Rack
- Defined in:
- lib/construqt/rack.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#location ⇒ Object
Returns the value of attribute location.
-
#name ⇒ Object
Returns the value of attribute name.
-
#pin ⇒ Object
Returns the value of attribute pin.
-
#total_high ⇒ Object
Returns the value of attribute total_high.
Instance Method Summary collapse
- #add_entry(positions, key) ⇒ Object
-
#initialize(name) ⇒ Rack
constructor
A new instance of Rack.
Constructor Details
#initialize(name) ⇒ Rack
Returns a new instance of Rack.
19 20 21 22 |
# File 'lib/construqt/rack.rb', line 19 def initialize(name) @name = name @entries = {} end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
17 18 19 |
# File 'lib/construqt/rack.rb', line 17 def description @description end |
#location ⇒ Object
Returns the value of attribute location.
15 16 17 |
# File 'lib/construqt/rack.rb', line 15 def location @location end |
#name ⇒ Object
Returns the value of attribute name.
16 17 18 |
# File 'lib/construqt/rack.rb', line 16 def name @name end |
#pin ⇒ Object
Returns the value of attribute pin.
18 19 20 |
# File 'lib/construqt/rack.rb', line 18 def pin @pin end |
#total_high ⇒ Object
Returns the value of attribute total_high.
14 15 16 |
# File 'lib/construqt/rack.rb', line 14 def total_high @total_high end |
Instance Method Details
#add_entry(positions, key) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/construqt/rack.rb', line 23 def add_entry(positions, key) if /[^0-9]+/.match(position.to_s) && 0 <= position.to_i && position.to_i <= total_high.to_i throw "position must be between 0 <= #{total_high} #{position}" end @entries[position] ||= {} throw "entry with key exists #{key} in Rack #{name}" if @entries[position][key] entry = Entry.new(key, self) @entries[position][key] = entry entry end |