README.md in open-weather-api-0.0.4 vs README.md in open-weather-api-0.0.5

- old
+ new

@@ -47,23 +47,21 @@ ````ruby Rails.configuration.open_weather_api ```` -### Other +### Generic ```ruby open_weather_api = OpenWeatherAPI::API.new api_key: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", default_language: 'es', default_units: 'metric', default_country_code: 'es' # ... ``` ---------------------------- Finally, you can use the different resources of the API: -**NOTE**: You can add manually any parameter you need for each request, and they will override the computed parameters. - ### Current Weather By city name: ````ruby @@ -104,34 +102,68 @@ ````ruby json = open_weather_api.current circle: { lat: -16.3319, lon: 28.5046 }, cities_count: 2 ```` -You can also use ruby blocks to handle the response: +For more information about the API, visit [http://openweathermap.org/current](http://openweathermap.org/current). +### Forecast + +#### Hourly (actually, every 3 hours, up to 5 days) + +By city name: + ````ruby -json = open_weather_api.current city: 'Santa Cruz de Tenerife', country_code: 'es' do |json| - puts JSON.pretty_generate(json) -end +json = open_weather_api.forecast :hourly, city: 'Santa Cruz de Tenerife', country_code: 'es' ```` -For more information about the API, visit [http://openweathermap.org/current](http://openweathermap.org/current). +By city id: -### Forecast +````ruby +json = open_weather_api.forecast :hourly, id: 6360638 +```` -TODO. +By geolocation: +````ruby +json = open_weather_api.forecast :hourly, lon: -16.20302, lat: 28.53924 +```` + +For more information about the API, visit [http://openweathermap.org/forecast5](http://openweathermap.org/forecast5). + ### Other Retrieve icon url: ````ruby open_weather_api.current city: 'Santa Cruz de Tenerife', country_code: 'es' do |json| puts "Icon url: #{api.icon_url json['weather'].first['icon']}" end ```` +You can add manually any parameter you need for each request, and they will override the computed parameters: + +````ruby +open_weather_api.current city: 'Balashikha', country_code: "ru", lang: "ru" +```` + +Also, you can define the response format with the `:mode` parameters. Valid formats are `:json` (returns a `Hash`), `:xml` and `:html` (both return a `String`): + +````ruby +open_weather_api.current city: 'Santa Cruz de Tenerife', mode: :xml do |xml_str| + puts "XML data: #{xml_str}" +end +```` + +You can use ruby blocks to handle the response: + +````ruby +open_weather_api.current city: 'Santa Cruz de Tenerife', country_code: 'es', mode: :json do |json| + puts JSON.pretty_generate(json) +end +```` + ## Authors ## This project has been developed by: | Avatar | Name | Nickname | Email | @@ -140,8 +172,9 @@ ## Contributing 1. Fork it ( [https://gitlab.com/wikiti-random-stuff/open-weather-api/fork/new](https://gitlab.com/wikiti-random-stuff/open-weather-api/fork/new) ) 2. Create your feature branch (`git checkout -b my-new-feature`) -3. Commit your changes (`git commit -am 'Add some feature'`) -4. Push to the branch (`git push origin my-new-feature`) -5. Create new Pull Request +3. Commit your changes (`git commit -am 'Add some feature'`) +4. Run tests (`rake test`) +5. Push to the branch (`git push origin my-new-feature`) +6. Create new Merge Request