Class: UrbanNews::Story
- Inherits:
-
Object
- Object
- UrbanNews::Story
- Defined in:
- lib/urban_news/story.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#credit ⇒ Object
Returns the value of attribute credit.
-
#summary ⇒ Object
Returns the value of attribute summary.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(title, summary, credit, url, content) ⇒ Story
constructor
A new instance of Story.
Constructor Details
#initialize(title, summary, credit, url, content) ⇒ Story
Returns a new instance of Story.
15 16 17 18 19 20 21 22 |
# File 'lib/urban_news/story.rb', line 15 def initialize(title, summary, credit, url, content) @title = title @summary = summary @credit = credit @url = url @content = content @@all << self end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
8 9 10 |
# File 'lib/urban_news/story.rb', line 8 def content @content end |
#credit ⇒ Object
Returns the value of attribute credit.
8 9 10 |
# File 'lib/urban_news/story.rb', line 8 def credit @credit end |
#summary ⇒ Object
Returns the value of attribute summary.
8 9 10 |
# File 'lib/urban_news/story.rb', line 8 def summary @summary end |
#title ⇒ Object
Returns the value of attribute title.
8 9 10 |
# File 'lib/urban_news/story.rb', line 8 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
8 9 10 |
# File 'lib/urban_news/story.rb', line 8 def url @url end |
Class Method Details
.all ⇒ Object
24 25 26 |
# File 'lib/urban_news/story.rb', line 24 def self.all @@all end |
.find(id) ⇒ Object
28 29 30 |
# File 'lib/urban_news/story.rb', line 28 def self.find(id) self.all[id-1] end |
.latest_posts ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/urban_news/story.rb', line 32 def self.latest_posts self.all.each do |story| puts "#{story.title}" puts "#{story.summary}" puts "#{story.credit}" puts "#{story.url}" puts "#{story.content}" end end |
.new_from_blog_page(s) ⇒ Object
11 12 13 |
# File 'lib/urban_news/story.rb', line 11 def self.new_from_blog_page(s) self.new(s[:title], s[:summary], s[:credit], s[:url], s[:content]) end |