Class: Freegeoip::Request
- Inherits:
-
Object
- Object
- Freegeoip::Request
- Defined in:
- lib/freegeoip/request.rb
Constant Summary collapse
- ENDPOINT =
"http://freegeoip.net/"- FORMAT =
'json'
Instance Attribute Summary collapse
-
#remote ⇒ Object
readonly
Returns the value of attribute remote.
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(remote) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(remote) ⇒ Request
Returns a new instance of Request.
12 13 14 |
# File 'lib/freegeoip/request.rb', line 12 def initialize(remote) @remote = remote end |
Instance Attribute Details
#remote ⇒ Object (readonly)
Returns the value of attribute remote.
10 11 12 |
# File 'lib/freegeoip/request.rb', line 10 def remote @remote end |
Instance Method Details
#get ⇒ Object
16 17 18 19 20 21 |
# File 'lib/freegeoip/request.rb', line 16 def get uri = URI(ENDPOINT + FORMAT + "/" + remote) res = Net::HTTP.get(uri) JSON.parse(res) end |