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.
-
#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 |
# File 'lib/tinyembedly/oembed.rb', line 18 def initialize( = {}) @api_key = [:api_key] || @@api_key @url = [:url] 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 |
#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
33 34 35 |
# File 'lib/tinyembedly/oembed.rb', line 33 def self.class.get(endpoint, :query => params) end |
#params ⇒ Object
37 38 39 |
# File 'lib/tinyembedly/oembed.rb', line 37 def params { :url => @url, :key => @api_key } end |
#to_hash ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/tinyembedly/oembed.rb', line 23 def to_hash response = case response.code when 200 response.parsed_response else raise ResponseError.new(response) end end |