Class: PecCalcClient::Region

Inherits:
Object
  • Object
show all
Defined in:
lib/pec_calc_client/region.rb

Constant Summary collapse

URL =
'http://pecom.ru/ru/calc/towns.php'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, towns) ⇒ Region

Returns a new instance of Region.



7
8
9
10
# File 'lib/pec_calc_client/region.rb', line 7

def initialize(name, towns)
  @name = name
  @towns = towns.collect { |id, name| Town.new id, name }
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/pec_calc_client/region.rb', line 5

def name
  @name
end

#townsObject (readonly)

Returns the value of attribute towns.



5
6
7
# File 'lib/pec_calc_client/region.rb', line 5

def towns
  @towns
end

Class Method Details

.allObject



12
13
14
15
# File 'lib/pec_calc_client/region.rb', line 12

def self.all
  @all = Connector.new(self::URL).request.to_hash.collect { |name, towns| new name, towns } if @all.nil?
  @all
end