Class: Oembedder::ProviderResponse
- Inherits:
-
Object
- Object
- Oembedder::ProviderResponse
- Defined in:
- lib/oembedder/provider_response.rb
Instance Attribute Summary collapse
-
#format ⇒ Object
readonly
attr_reader :type, :version, :title, :author_name, :author_url, :provider_name, :provider_url, :cache_age, :thumbnail_url, :thumbnail_width, :thumbnail_height, :url, :html, :width, :height.
-
#has_error ⇒ Object
readonly
attr_reader :type, :version, :title, :author_name, :author_url, :provider_name, :provider_url, :cache_age, :thumbnail_url, :thumbnail_width, :thumbnail_height, :url, :html, :width, :height.
-
#raw_data ⇒ Object
readonly
attr_reader :type, :version, :title, :author_name, :author_url, :provider_name, :provider_url, :cache_age, :thumbnail_url, :thumbnail_width, :thumbnail_height, :url, :html, :width, :height.
-
#status ⇒ Object
readonly
attr_reader :type, :version, :title, :author_name, :author_url, :provider_name, :provider_url, :cache_age, :thumbnail_url, :thumbnail_width, :thumbnail_height, :url, :html, :width, :height.
Class Method Summary collapse
Instance Method Summary collapse
- #handle_status(faraday_response) ⇒ Object
-
#initialize(params = {}) ⇒ ProviderResponse
constructor
A new instance of ProviderResponse.
- #method_missing(name) ⇒ Object
- #parse(response) ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ ProviderResponse
Returns a new instance of ProviderResponse.
13 14 15 16 |
# File 'lib/oembedder/provider_response.rb', line 13 def initialize(params = {}) @has_error = false @format = params[:format] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/oembedder/provider_response.rb', line 27 def method_missing(name) if data = find_data(name) data else super end end |
Instance Attribute Details
#format ⇒ Object (readonly)
attr_reader :type, :version, :title, :author_name, :author_url, :provider_name, :provider_url, :cache_age, :thumbnail_url, :thumbnail_width, :thumbnail_height, :url, :html, :width, :height
4 5 6 |
# File 'lib/oembedder/provider_response.rb', line 4 def format @format end |
#has_error ⇒ Object (readonly)
attr_reader :type, :version, :title, :author_name, :author_url, :provider_name, :provider_url, :cache_age, :thumbnail_url, :thumbnail_width, :thumbnail_height, :url, :html, :width, :height
4 5 6 |
# File 'lib/oembedder/provider_response.rb', line 4 def has_error @has_error end |
#raw_data ⇒ Object (readonly)
attr_reader :type, :version, :title, :author_name, :author_url, :provider_name, :provider_url, :cache_age, :thumbnail_url, :thumbnail_width, :thumbnail_height, :url, :html, :width, :height
4 5 6 |
# File 'lib/oembedder/provider_response.rb', line 4 def raw_data @raw_data end |
#status ⇒ Object (readonly)
attr_reader :type, :version, :title, :author_name, :author_url, :provider_name, :provider_url, :cache_age, :thumbnail_url, :thumbnail_width, :thumbnail_height, :url, :html, :width, :height
4 5 6 |
# File 'lib/oembedder/provider_response.rb', line 4 def status @status end |
Class Method Details
.create(format, faraday_response) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/oembedder/provider_response.rb', line 6 def self.create(format, faraday_response) pr = ProviderResponse.new(format: format) pr.handle_status faraday_response pr.parse faraday_response.body pr end |
Instance Method Details
#handle_status(faraday_response) ⇒ Object
18 19 20 21 |
# File 'lib/oembedder/provider_response.rb', line 18 def handle_status(faraday_response) @status = faraday_response.status @has_error = true unless faraday_response.status == 200 end |
#parse(response) ⇒ Object
23 24 25 |
# File 'lib/oembedder/provider_response.rb', line 23 def parse(response) @raw_data = response end |