Class: Oembed::Media
Instance Attribute Summary collapse
-
#format ⇒ Object
Returns the value of attribute format.
-
#html ⇒ Object
Returns the value of attribute html.
-
#media_url ⇒ Object
Returns the value of attribute media_url.
-
#title ⇒ Object
Returns the value of attribute title.
Attributes inherited from Providers
Instance Method Summary collapse
- #get_info ⇒ Object
-
#initialize(url) ⇒ Media
constructor
A new instance of Media.
- #set_attributes(att) ⇒ Object
Constructor Details
#initialize(url) ⇒ Media
Returns a new instance of Media.
7 8 9 10 11 12 |
# File 'lib/oembed/media.rb', line 7 def initialize(url) @format = 'json' @url = url @sites = ::Providers.new.sites get_info end |
Instance Attribute Details
#format ⇒ Object
Returns the value of attribute format.
5 6 7 |
# File 'lib/oembed/media.rb', line 5 def format @format end |
#html ⇒ Object
Returns the value of attribute html.
5 6 7 |
# File 'lib/oembed/media.rb', line 5 def html @html end |
#media_url ⇒ Object
Returns the value of attribute media_url.
5 6 7 |
# File 'lib/oembed/media.rb', line 5 def media_url @media_url end |
#title ⇒ Object
Returns the value of attribute title.
5 6 7 |
# File 'lib/oembed/media.rb', line 5 def title @title end |
Instance Method Details
#get_info ⇒ Object
14 15 16 17 18 19 |
# File 'lib/oembed/media.rb', line 14 def get_info find_provider url = URI.parse(@base_url + @url) http_get = Net::HTTP.get(url) set_attributes(http_get) end |
#set_attributes(att) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/oembed/media.rb', line 21 def set_attributes(att) parsed_data = JSON.parse(att) @title = parsed_data['title'] @media_url = parsed_data['url'] @format = parsed_data['type'] @html = parsed_data['html'] if @format == 'video' end |