Skip to content
This repository was archived by the owner on Apr 25, 2020. It is now read-only.

Commit afa3bee

Browse files
committed
Explain HTTP adapter configuration
1 parent 210e193 commit afa3bee

1 file changed

Lines changed: 23 additions & 5 deletions

File tree

README.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ You can then make requests to the `Forecast::IO.forecast(latitude, longitide, op
3838

3939
Valid options in the `options` hash are:
4040

41-
* `:time` - UNIX time in seconds since the Unix epoch.
41+
* `:time` - Unix time in seconds.
4242
* `:params` - Query parameters that can contain the following:
4343
* `:jsonp` - JSONP callback.
4444
* `:units` - Return the API response in SI units, rather than the default Imperial units.
@@ -47,31 +47,49 @@ Valid options in the `options` hash are:
4747
Get the current forecast:
4848

4949
```ruby
50-
forecast = Forecast::IO.forecast('37.8267','-122.423')
50+
forecast = Forecast::IO.forecast(37.8267, -122.423)
5151
```
5252

5353
Get the current forecast at a given time:
5454

5555
```ruby
56-
forecast = Forecast::IO.forecast('37.8267','-122.423', time: Time.new(2013, 3, 11).to_i)
56+
forecast = Forecast::IO.forecast(37.8267, -122.423, time: Time.new(2013, 3, 11).to_i)
5757
```
5858

5959
Get the current forecast and use SI units:
6060

6161
```ruby
62-
forecast = Forecast::IO.forecast('37.8267','-122.423', params: {units: 'si'})
62+
forecast = Forecast::IO.forecast(37.8267, -122.423, params: { units: 'si' })
6363
```
6464

6565
The `forecast(...)` method will return a response that you can interact with in a more-friendly way, such as:
6666

6767
```ruby
68-
forecast = Forecast::IO.forecast('37.8267','-122.423')
68+
forecast = Forecast::IO.forecast(37.8267, -122.423)
6969
forecast.latitude
7070
forecast.longitude
7171
```
7272

7373
Please refer to the [forecast.io](https://developer.darkskyapp.com/docs/v2) API documentation for more information on the full response properties.
7474

75+
The HTTP requests are made with [Faraday](https://github.com/lostisland/faraday), which uses `Net::HTTP` by default. Changing the adapter is easy:
76+
77+
```ruby
78+
require 'typhoeus/adapters/faraday'
79+
80+
Faraday.default_adapter = :typhoeus
81+
```
82+
83+
Alternatively:
84+
85+
```ruby
86+
require 'typhoeus/adapters/faraday'
87+
88+
Forecast::IO.connection = Faraday.new do |builder|
89+
builder.adapter :typhoeus
90+
end
91+
```
92+
7593
## Contributing to forecast_io
7694

7795
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet

0 commit comments

Comments
 (0)