Module: Vk::DSL::Database
- Included in:
- Vk::DSL
- Defined in:
- lib/vk/dsl/database.rb
Instance Method Summary collapse
- #get_cities(options = {}) ⇒ Object
-
#get_cities_by_id(city_ids) ⇒ Array<Hash>
Cities’ names.
- #get_city_by_id(cid) ⇒ Vk::City (also: #get_city)
- #get_countries(options = {}) ⇒ Object
-
#get_countries_by_id(country_ids) ⇒ Array<Vk::Country>
Countries’ names.
- #get_country_by_id(country_id) ⇒ Vk::Country (also: #get_country)
- #get_regions(country_id, options = {}) ⇒ Vk::Result<Vk::Region>
- #get_street_by_id(street_id) ⇒ Object (also: #get_street)
-
#get_streets_by_id(street_ids) ⇒ Array<Vk::Country>
Countries’ names.
Instance Method Details
#get_cities(options = {}) ⇒ Object
98 99 100 101 102 103 104 105 |
# File 'lib/vk/dsl/database.rb', line 98 def get_cities( = {}) require 'vk/city' raise 'No country_id attribute given for database.getRegions' unless [:country_id] [:code] = [:code].join(',') if [:code] Vk::Result.new('database.getCities', Vk::City, , country_id: [:country_id], region_id: [:region_id]) end |
#get_cities_by_id(city_ids) ⇒ Array<Hash>
Cities’ names
76 77 78 79 80 81 82 83 |
# File 'lib/vk/dsl/database.rb', line 76 def get_cities_by_id(city_ids) require 'vk/city' city_ids = Array(city_ids) raise Vk::TooMuchArguments.new('database.getCitiesById', 'city_ids', 1000) if city_ids > 1000 request('database.getCitiesById', city_ids: city_ids.join(',')).map do |city| Vk::City.new(city) end end |
#get_city_by_id(cid) ⇒ Vk::City Also known as: get_city
86 87 88 |
# File 'lib/vk/dsl/database.rb', line 86 def get_city_by_id(cid) get_cities_by_id(cid).first end |
#get_countries(options = {}) ⇒ Object
11 12 13 14 15 |
# File 'lib/vk/dsl/database.rb', line 11 def get_countries( = {}) [:need_all] = 1 if [:need_all] [:code] = [:code].join(',') if [:code] Vk::Result.new('database.getCountries', Vk::Country, ) end |
#get_countries_by_id(country_ids) ⇒ Array<Vk::Country>
Countries’ names
20 21 22 23 24 25 26 27 |
# File 'lib/vk/dsl/database.rb', line 20 def get_countries_by_id(country_ids) require 'vk/country' country_ids = Array(country_ids) raise Vk::TooMuchArguments.new('database.getCountriesById', 'country_ids', 1000) if country_ids > 1000 request('database.getCountriesById', country_ids: country_ids.join(',')).map do |country| Vk::Country.new(country) end end |
#get_country_by_id(country_id) ⇒ Vk::Country Also known as: get_country
31 32 33 |
# File 'lib/vk/dsl/database.rb', line 31 def get_country_by_id(country_id) get_countries_by_id(country_id).first end |
#get_regions(country_id, options = {}) ⇒ Vk::Result<Vk::Region>
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/vk/dsl/database.rb', line 43 def get_regions(country_id, = {}) if country_id.is_a?(:hash) country_id = .delete(:country_id) do raise 'No country_id attribute given for database.getRegions' end end require 'vk/region' [:code] = [:code].join(',') if [:code] Vk::Result.new('database.getRegions', Vk::Region, , country_id: country_id) end |
#get_street_by_id(street_id) ⇒ Object Also known as: get_street
67 68 69 |
# File 'lib/vk/dsl/database.rb', line 67 def get_street_by_id(street_id) get_streets_by_id(street_id).first end |
#get_streets_by_id(street_ids) ⇒ Array<Vk::Country>
Countries’ names
57 58 59 60 61 62 63 64 |
# File 'lib/vk/dsl/database.rb', line 57 def get_streets_by_id(street_ids) require 'vk/street' street_ids = Array(street_ids) raise Vk::TooMuchArguments.new('database.getCountriesById', 'street_ids', 1000) if street_ids > 1000 request('database.getCountriesById', street_ids: street_ids.join(',')).map do |street| Vk::Street.new(street) end end |