Class: Waffle::Maker::Api::Base
- Inherits:
-
Object
- Object
- Waffle::Maker::Api::Base
- Defined in:
- lib/waffle/maker/api/base.rb
Direct Known Subclasses
Constant Summary collapse
- FORCE_ENCODING =
"UTF-8"
Instance Attribute Summary collapse
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
Instance Attribute Details
#headers ⇒ Object
Returns the value of attribute headers.
8 9 10 |
# File 'lib/waffle/maker/api/base.rb', line 8 def headers @headers end |
#url ⇒ Object
Returns the value of attribute url.
8 9 10 |
# File 'lib/waffle/maker/api/base.rb', line 8 def url @url end |
Instance Method Details
#body_in_hash_format ⇒ Object
10 11 12 13 14 |
# File 'lib/waffle/maker/api/base.rb', line 10 def body_in_hash_format get.then do |response| JSON.parse(response.body.force_encoding(FORCE_ENCODING)) end end |
#body_in_json_format ⇒ Object
16 17 18 19 20 |
# File 'lib/waffle/maker/api/base.rb', line 16 def body_in_json_format get.then do |response| response.body.force_encoding(FORCE_ENCODING) end end |
#get ⇒ Object
22 23 24 |
# File 'lib/waffle/maker/api/base.rb', line 22 def get @get ||= http.get(url, headers) end |
#http ⇒ Object
26 27 28 29 30 |
# File 'lib/waffle/maker/api/base.rb', line 26 def http Net::HTTP.new(url.host, url.port).tap do |http| http.use_ssl = (url.scheme === "https") end end |