class Oembedder::ProviderResponse
Attributes
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
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
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
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
Public Class Methods
# 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
# File lib/oembedder/provider_response.rb, line 13 def initialize(params = {}) @has_error = false @format = params[:format] end
Public Instance Methods
# 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
# File lib/oembedder/provider_response.rb, line 27 def method_missing(name) if data = find_data(name) data else super end end
# File lib/oembedder/provider_response.rb, line 23 def parse(response) @raw_data = response end
Private Instance Methods
# File lib/oembedder/provider_response.rb, line 36 def find_data(name) case self.format when :json @raw_data[name.to_s] if @raw_data.has_key?(name.to_s) when :xml @raw_data['oembed'][name.to_s] if @raw_data['oembed'].has_key?(name.to_s) else false end end