Class: C80MapFloors::SearchResult
- Inherits:
-
Object
- Object
- C80MapFloors::SearchResult
- Defined in:
- lib/search_result.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #add_area(area_id) ⇒ Object
- #add_building(building_id) ⇒ Object
- #add_floor(floor_id) ⇒ Object
- #areas ⇒ Object
- #buildings ⇒ Object
- #buildings_shops_count ⇒ Object
-
#floors ⇒ Object
for testing (see /home/scout/git/research/kata_ruby/spec/003_my_arrays_spec.rb).
- #floors_shops_count ⇒ Object
-
#initialize ⇒ SearchResult
constructor
A new instance of SearchResult.
Constructor Details
#initialize ⇒ SearchResult
Returns a new instance of SearchResult.
11 12 13 14 15 16 17 18 19 |
# File 'lib/search_result.rb', line 11 def initialize @data = { buildings: [], # содержит айдишники полигонов зданий, в которых найдены магазины buildings_shops_count: [], # содержит кол-во найденных в *соответствующем* здании магазинов floors: [], # содержит айдишники картинок этажей, в которых найдены магазины floors_shops_count: [], # содержит кол-во найденных магазинов на *соответствующей* картинке этажа areas: [] # сюда собираем айдишники полигонов площадей } end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
9 10 11 |
# File 'lib/search_result.rb', line 9 def data @data end |
Instance Method Details
#add_area(area_id) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/search_result.rb', line 41 def add_area(area_id) indx = @data[:areas].index(area_id.to_i) if indx.nil? @data[:areas] << area_id.to_i end end |
#add_building(building_id) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/search_result.rb', line 31 def add_building(building_id) indx = @data[:buildings].index(building_id.to_i) if indx.nil? @data[:buildings] << building_id.to_i @data[:buildings_shops_count] << 1 else @data[:buildings_shops_count][indx] += 1 end end |
#add_floor(floor_id) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/search_result.rb', line 21 def add_floor(floor_id) indx = @data[:floors].index(floor_id.to_i) if indx.nil? @data[:floors] << floor_id.to_i @data[:floors_shops_count] << 1 else @data[:floors_shops_count][indx] += 1 end end |
#areas ⇒ Object
64 65 66 |
# File 'lib/search_result.rb', line 64 def areas @data[:areas] end |
#buildings ⇒ Object
60 61 62 |
# File 'lib/search_result.rb', line 60 def buildings @data[:buildings] end |
#buildings_shops_count ⇒ Object
68 69 70 |
# File 'lib/search_result.rb', line 68 def buildings_shops_count @data[:buildings_shops_count] end |
#floors ⇒ Object
for testing (see /home/scout/git/research/kata_ruby/spec/003_my_arrays_spec.rb)
52 53 54 |
# File 'lib/search_result.rb', line 52 def floors @data[:floors] end |
#floors_shops_count ⇒ Object
56 57 58 |
# File 'lib/search_result.rb', line 56 def floors_shops_count @data[:floors_shops_count] end |