Class: Construqt::Racks::Rack

Inherits:
Object
  • Object
show all
Defined in:
lib/construqt/rack.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#descriptionObject

Returns the value of attribute description.



17
18
19
# File 'lib/construqt/rack.rb', line 17

def description
  @description
end

#locationObject

Returns the value of attribute location.



15
16
17
# File 'lib/construqt/rack.rb', line 15

def location
  @location
end

#nameObject

Returns the value of attribute name.



16
17
18
# File 'lib/construqt/rack.rb', line 16

def name
  @name
end

#pinObject

Returns the value of attribute pin.



18
19
20
# File 'lib/construqt/rack.rb', line 18

def pin
  @pin
end

#total_highObject

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