Class: Ryba::Address
- Inherits:
-
Object
- Object
- Ryba::Address
- Defined in:
- lib/ryba/address.rb
Constant Summary collapse
- BuildingFormats =
[ [ 'д. #', 90 ], [ 'д.#', 80 ], [ 'д. #/?', 15 ], [ 'д. #к?', 10 ], [ 'стр. #', 10 ], [ 'д.#/?', 5 ], [ 'д.#к?', 5 ], [ 'стр.#', 5 ], ].freeze
- ApartmentFormats =
[ [ 'кв. #', 10 ], [ 'оф. #', 10 ], [ '? этаж', 2 ], [ 'кв.#', 5 ], [ 'оф.#', 5 ], [ '?-й эт.', 1 ], ]
Class Method Summary collapse
- .address ⇒ Object
- .city ⇒ Object
- .full_city ⇒ Object
- .index ⇒ Object
- .postal ⇒ Object
- .street ⇒ Object
Class Method Details
.address ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/ryba/address.rb', line 50 def address building = Ryba.pick(1..200) apartment = Ryba.pick(1..300) separator = Ryba.pick([' ', ', ']) street + separator + if rand(10) < 2 "#{building}-#{apartment}" else formatter = lambda do |fmts, num| Ryba.weighted_pick(fmts).gsub('#', num.to_s).gsub('?', Ryba.pick(1..9).to_s) end building = formatter.call(BuildingFormats, building) apartment = formatter.call(ApartmentFormats, apartment) "#{building}#{separator}#{apartment}" end end |
.city ⇒ Object
9 10 11 |
# File 'lib/ryba/address.rb', line 9 def city Ryba.pick(Data::AllCities).gsub('_', ' ') end |
.full_city ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ryba/address.rb', line 13 def full_city cty = Ryba.pick(Data::AllCities) h_cty = cty.gsub('_', ' ') region = Ryba.pick(Data::RegionByCities[cty]) if Data::CitiesByRegion[region].first == cty "г. #{h_cty}" else "#{region}, г. #{h_cty}" end end |
.postal ⇒ Object
70 71 72 |
# File 'lib/ryba/address.rb', line 70 def postal "#{index}, #{full_city}, #{address}" end |
.street ⇒ Object
26 27 28 |
# File 'lib/ryba/address.rb', line 26 def street Ryba.pick(Data::StreetNames) end |