Class: Pebbles::VoyageConferenceRoom::Floor
- Inherits:
-
Object
- Object
- Pebbles::VoyageConferenceRoom::Floor
- Defined in:
- lib/pebbles/voyage_conference_room/floor.rb
Instance Attribute Summary collapse
-
#floor_map ⇒ Object
readonly
Returns the value of attribute floor_map.
-
#rooms ⇒ Object
readonly
Returns the value of attribute rooms.
Instance Method Summary collapse
-
#initialize ⇒ Floor
constructor
A new instance of Floor.
- #show_map(options) ⇒ Object
Constructor Details
#initialize ⇒ Floor
Returns a new instance of Floor.
6 7 8 9 10 11 |
# File 'lib/pebbles/voyage_conference_room/floor.rb', line 6 def initialize gem_spec = Gem::Specification.find_by_name("pebbles-voyage_conference_room") rooms_spec = YAML.load_file("#{gem_spec.gem_dir}/config/rooms.yml") @floor_map = rooms_spec["floor_map"] @rooms = rooms_spec["rooms"] end |
Instance Attribute Details
#floor_map ⇒ Object (readonly)
Returns the value of attribute floor_map.
12 13 14 |
# File 'lib/pebbles/voyage_conference_room/floor.rb', line 12 def floor_map @floor_map end |
#rooms ⇒ Object (readonly)
Returns the value of attribute rooms.
12 13 14 |
# File 'lib/pebbles/voyage_conference_room/floor.rb', line 12 def rooms @rooms end |
Instance Method Details
#show_map(options) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/pebbles/voyage_conference_room/floor.rb', line 14 def show_map() name = ["name"].to_s.downcase code = ["code"] selected_rooms = rooms.select! do |k, v| k == name || v["aliases"].include?(name) || v["code"] == code end map = floor_map if ["with_code"] selected_rooms.map{ |k,v| v["code"] }.each{ |code| map.gsub!(code, "/".color(:red)) } else selected_rooms.map{ |k,v| v["code"] }.each{ |code| map.gsub!(code, '/') } map.gsub!(/[a-z]/, ' ') map.gsub!("/", "/".color(:red)) end map end |