This is a workshop on Object-Oriented Design (https://mokevnin.timepad.ru/event/792995/).
Add this line to your application's Gemfile:
gem 'oop-workshop'
And then execute:
$ bundle
Or install it yourself as:
$ gem install oop-workshop
Библиотека, которая по ip адресу возвращает гео-информацию используя сервис http://ip-api.com
location = Oop::Workshop.search_location_by_ip '134.234.3.2'
location.query # => "134.234.3.2"
location.status # => "success"
location.country # => "United States"
location.city # => "Sierra Vista (Fort Huachuca)"
location.country_code # => "US"
location.lat # => 31.5552
location.lon # => -110.35
location.region_name # => "Arizona"
location.timezone # => "America/Phoenix"
location.zip # => "85613"
https://github.com/mokevnin/oop-workshop-materials/blob/master/pipline/index.ex
Переложите это вычисление на ваш язык
Oop::Workshop.chain # => "BINS"
Утилита командной строки, которая возвращает информацию о погоде для указанного города. Она должна уметь обращаться к двум разным сервисам, каждый из которых выбирается флагом --service.
exe/weather weather --service Metaweather London # => "Heavy Cloud, 18.28"
exe/weather weather -s Fake Miami # => "Beautiful weather"
Oop::Workshop.weather('Metaweather', 'London') # => "Heavy Cloud, 18.28"
- or -
w = Oop::Workshop.Weather.init('Metaweather')
w.weather 'London' # => "Heavy Cloud, 18.28"
w.weather('Miami', 'Fake') # => "Beautiful weather"
- or with another weather service -
class AnotherWeatherService
def weather(city)
# weather definition
'Cloud, 19'
end
end
w = Oop::Workshop.Weather.init('Metaweather', { 'Another' => AnotherWeatherService.new })
w.weather 'London' # => "Heavy Cloud, 18.28"
w.weather('London', 'Another') # => "Cloud, 19"
https://oop-workshop.herokuapp.com
https://oop-workshop.herokuapp.com/ip
https://oop-workshop.herokuapp.com/weather
bin/sinatra