Class: Bateman::TwitterCard
- Inherits:
-
Object
- Object
- Bateman::TwitterCard
- Defined in:
- lib/bateman/twitter_card.rb
Instance Attribute Summary collapse
-
#card ⇒ Object
readonly
Returns the value of attribute card.
-
#creator ⇒ Object
readonly
Returns the value of attribute creator.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#image ⇒ Object
readonly
Returns the value of attribute image.
-
#site ⇒ Object
readonly
Returns the value of attribute site.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #fetch ⇒ Object
-
#initialize(url) ⇒ TwitterCard
constructor
A new instance of TwitterCard.
- #process_html_document ⇒ Object
- #set_attributes_from_response ⇒ Object
Constructor Details
#initialize(url) ⇒ TwitterCard
Returns a new instance of TwitterCard.
5 6 7 8 9 10 11 |
# File 'lib/bateman/twitter_card.rb', line 5 def initialize(url) @uri = URI.parse(url) fetch process_html_document set_attributes_from_response end |
Instance Attribute Details
#card ⇒ Object (readonly)
Returns the value of attribute card.
3 4 5 |
# File 'lib/bateman/twitter_card.rb', line 3 def card @card end |
#creator ⇒ Object (readonly)
Returns the value of attribute creator.
3 4 5 |
# File 'lib/bateman/twitter_card.rb', line 3 def creator @creator end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
3 4 5 |
# File 'lib/bateman/twitter_card.rb', line 3 def description @description end |
#image ⇒ Object (readonly)
Returns the value of attribute image.
3 4 5 |
# File 'lib/bateman/twitter_card.rb', line 3 def image @image end |
#site ⇒ Object (readonly)
Returns the value of attribute site.
3 4 5 |
# File 'lib/bateman/twitter_card.rb', line 3 def site @site end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
3 4 5 |
# File 'lib/bateman/twitter_card.rb', line 3 def title @title end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
3 4 5 |
# File 'lib/bateman/twitter_card.rb', line 3 def url @url end |
Instance Method Details
#fetch ⇒ Object
23 24 25 26 27 |
# File 'lib/bateman/twitter_card.rb', line 23 def fetch @response = HTTParty.get(@uri.to_s) self end |
#process_html_document ⇒ Object
29 30 31 32 33 |
# File 'lib/bateman/twitter_card.rb', line 29 def process_html_document @html_document = Nokogiri::HTML(@response.body) self end |
#set_attributes_from_response ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/bateman/twitter_card.rb', line 13 def set_attributes_from_response @card = Bateman::CardAttribute.new(@html_document).to_s @creator = Bateman::CreatorAttribute.new(@html_document).to_s @description = Bateman::DescriptionAttribute.new(@html_document).to_s @image = Bateman::ImageAttribute.new(@html_document).to_s @site = Bateman::SiteAttribute.new(@html_document).to_s @title = Bateman::TitleAttribute.new(@html_document).to_s @url = Bateman::UrlAttribute.new(@html_document, @uri).to_s end |