Class: Tinyembedly::Oembed
- Inherits:
-
Object
- Object
- Tinyembedly::Oembed
- Includes:
- HTTParty
- Defined in:
- lib/tinyembedly/oembed.rb
Constant Summary collapse
- @@api_key =
nil
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#other_params ⇒ Object
readonly
Returns the value of attribute other_params.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #get_oembed ⇒ Object
-
#initialize(options = {}) ⇒ Oembed
constructor
A new instance of Oembed.
- #params ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Oembed
Returns a new instance of Oembed.
18 19 20 21 22 |
# File 'lib/tinyembedly/oembed.rb', line 18 def initialize( = {}) @api_key = .delete(:api_key) || @@api_key @url = .delete(:url) @other_params = end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
6 7 8 |
# File 'lib/tinyembedly/oembed.rb', line 6 def api_key @api_key end |
#other_params ⇒ Object (readonly)
Returns the value of attribute other_params.
6 7 8 |
# File 'lib/tinyembedly/oembed.rb', line 6 def other_params @other_params end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
6 7 8 |
# File 'lib/tinyembedly/oembed.rb', line 6 def response @response end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
6 7 8 |
# File 'lib/tinyembedly/oembed.rb', line 6 def url @url end |
Class Method Details
.api_key=(value) ⇒ Object
9 10 11 |
# File 'lib/tinyembedly/oembed.rb', line 9 def self.api_key=(value) @@api_key = value end |
Instance Method Details
#get_oembed ⇒ Object
34 35 36 |
# File 'lib/tinyembedly/oembed.rb', line 34 def self.class.get(endpoint, :query => params) end |
#params ⇒ Object
38 39 40 |
# File 'lib/tinyembedly/oembed.rb', line 38 def params { :url => @url, :key => @api_key }.merge(@other_params) end |
#to_hash ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/tinyembedly/oembed.rb', line 24 def to_hash response = case response.code when 200 response.parsed_response else raise ResponseError.new(response) end end |