Class: Frostbitten::Map
- Inherits:
-
Hashie::Trash
- Object
- Hashie::Trash
- Frostbitten::Map
- Defined in:
- lib/frostbitten/map.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data, gamemode = nil, round_count = nil) ⇒ Map
constructor
A new instance of Map.
Constructor Details
#initialize(data, gamemode = nil, round_count = nil) ⇒ Map
Returns a new instance of Map.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/frostbitten/map.rb', line 22 def initialize(data,gamemode=nil,round_count=nil) if data.is_a? Array self.name = data[0] self.gamemode = data[1] self.round_count = data[2] elsif data.is_a? Hash self.name = data["name"] self.gamemode = data["gamemode"] self.round_count = data["round_count"] elsif data.is_a? String self.name = data self.gamemode = gamemode self.round_count = round_count end end |
Class Method Details
.maps_from_list(list, index = 0) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/frostbitten/map.rb', line 6 def maps_from_list(list,index=0) number_of_maps = list.slice!(index).to_i number_of_words_per_map = list.slice!(index).to_i columns = number_of_maps*number_of_words_per_map return [].tap do |maps| list.slice(index,columns).each_slice(number_of_words_per_map) do |map_data| maps << Map.new(map_data) end end end |