Class: Hallway
- Inherits:
-
DrawableObject
- Object
- DrawableObject
- Hallway
- Defined in:
- lib/hallways/hallway.rb
Direct Known Subclasses
Constant Summary collapse
- HALLWAYS_LENGTH =
Should be half room size
6
- HALLWAYS_WIDTH =
2
Constants inherited from DrawableObject
DrawableObject::BACKGROUND_COLOR, DrawableObject::GRID_COLOR, DrawableObject::SQUARE_SIZE_IN_PIXELS, DrawableObject::TEXT_COLOR
Instance Attribute Summary collapse
-
#disabled ⇒ Object
readonly
Returns the value of attribute disabled.
-
#hallway_id ⇒ Object
Returns the value of attribute hallway_id.
-
#rooms ⇒ Object
readonly
Returns the value of attribute rooms.
Instance Method Summary collapse
- #disable! ⇒ Object
- #get_direction_array(rooms_keys, room, input_output) ⇒ Object
-
#initialize ⇒ Hallway
constructor
A new instance of Hallway.
- #set_draw_base_room(draw_base_room) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize ⇒ Hallway
Returns a new instance of Hallway.
12 13 14 15 |
# File 'lib/hallways/hallway.rb', line 12 def initialize @disabled = false @hallway_id = nil end |
Instance Attribute Details
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled.
5 6 7 |
# File 'lib/hallways/hallway.rb', line 5 def disabled @disabled end |
#hallway_id ⇒ Object
Returns the value of attribute hallway_id.
5 6 7 |
# File 'lib/hallways/hallway.rb', line 5 def hallway_id @hallway_id end |
#rooms ⇒ Object (readonly)
Returns the value of attribute rooms.
5 6 7 |
# File 'lib/hallways/hallway.rb', line 5 def rooms @rooms end |
Instance Method Details
#disable! ⇒ Object
17 18 19 |
# File 'lib/hallways/hallway.rb', line 17 def disable! @disabled = true end |
#get_direction_array(rooms_keys, room, input_output) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/hallways/hallway.rb', line 29 def get_direction_array( rooms_keys, room, input_output ) return [ nil, nil ] if disabled return [ input_output[0], self ] if rooms_keys[0] == room.top_left_array return [ input_output[1], self ] if rooms_keys[1] == room.top_left_array [ nil, nil ] end |
#set_draw_base_room(draw_base_room) ⇒ Object
21 22 23 |
# File 'lib/hallways/hallway.rb', line 21 def set_draw_base_room( draw_base_room ) @draw_base_room = draw_base_room end |
#to_hash ⇒ Object
25 26 27 |
# File 'lib/hallways/hallway.rb', line 25 def to_hash { hallway_id: @hallway_id, klass: self.class.name, disabled: @disabled, draw_base_room: @draw_base_room.id } end |