Class: WikiOnThisDay::Snippet
- Inherits:
-
Object
- Object
- WikiOnThisDay::Snippet
- Defined in:
- lib/wiki_on_this_day/snippet.rb
Instance Attribute Summary collapse
-
#article_abstract ⇒ Object
Returns the value of attribute article_abstract.
-
#link_url ⇒ Object
Returns the value of attribute link_url.
-
#text ⇒ Object
Returns the value of attribute text.
-
#year ⇒ Object
Returns the value of attribute year.
Instance Method Summary collapse
-
#initialize(args) ⇒ Snippet
constructor
A new instance of Snippet.
- #print ⇒ Object
Constructor Details
#initialize(args) ⇒ Snippet
Returns a new instance of Snippet.
4 5 6 7 8 9 |
# File 'lib/wiki_on_this_day/snippet.rb', line 4 def initialize(args) self.year = args[:year] if args[:year] self.link_url = args[:link_url] if args[:link_url] self.text = args[:text].gsub(/\W\(pictured\)/,'') if args[:text] self.article_abstract = WikiOnThisDay::Scraper.new(self.link_url).html_doc.css('div#mw-content-text > p').first.text if self.link_url end |
Instance Attribute Details
#article_abstract ⇒ Object
Returns the value of attribute article_abstract.
2 3 4 |
# File 'lib/wiki_on_this_day/snippet.rb', line 2 def article_abstract @article_abstract end |
#link_url ⇒ Object
Returns the value of attribute link_url.
2 3 4 |
# File 'lib/wiki_on_this_day/snippet.rb', line 2 def link_url @link_url end |
#text ⇒ Object
Returns the value of attribute text.
2 3 4 |
# File 'lib/wiki_on_this_day/snippet.rb', line 2 def text @text end |
#year ⇒ Object
Returns the value of attribute year.
2 3 4 |
# File 'lib/wiki_on_this_day/snippet.rb', line 2 def year @year end |
Instance Method Details
#print ⇒ Object
11 12 13 |
# File 'lib/wiki_on_this_day/snippet.rb', line 11 def print WikiOnThisDay::Printer.new(self).print end |