Class: Hallway

Inherits:
DrawableObject show all
Defined in:
lib/hallways/hallway.rb

Direct Known Subclasses

HorizontalHallway, VerticalHallway

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

Instance Method Summary collapse

Constructor Details

#initializeHallway

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

#disabledObject (readonly)

Returns the value of attribute disabled.



5
6
7
# File 'lib/hallways/hallway.rb', line 5

def disabled
  @disabled
end

#hallway_idObject

Returns the value of attribute hallway_id.



5
6
7
# File 'lib/hallways/hallway.rb', line 5

def hallway_id
  @hallway_id
end

#roomsObject (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_hashObject



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