Class: KdnuggetsRoundup::Article

Inherits:
Object
  • Object
show all
Defined in:
lib/article.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, url) ⇒ Article



6
7
8
9
10
11
12
# File 'lib/article.rb', line 6

def initialize(title, url)
  @title = title
  @url = url
  @popular = false
  @shared = false
  @@all << self
end

Instance Attribute Details

#authorObject

Returns the value of attribute author.



3
4
5
# File 'lib/article.rb', line 3

def author
  @author
end

#excerptObject

Returns the value of attribute excerpt.



3
4
5
# File 'lib/article.rb', line 3

def excerpt
  @excerpt
end

Returns the value of attribute popular.



3
4
5
# File 'lib/article.rb', line 3

def popular
  @popular
end

#sharedObject

Returns the value of attribute shared.



3
4
5
# File 'lib/article.rb', line 3

def shared
  @shared
end

#summaryObject

Returns the value of attribute summary.



3
4
5
# File 'lib/article.rb', line 3

def summary
  @summary
end

#tagsObject

Returns the value of attribute tags.



3
4
5
# File 'lib/article.rb', line 3

def tags
  @tags
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/article.rb', line 3

def title
  @title
end

#urlObject

Returns the value of attribute url.



3
4
5
# File 'lib/article.rb', line 3

def url
  @url
end

Class Method Details

.allObject



38
39
40
# File 'lib/article.rb', line 38

def self.all
  @@all
end

.find_by_title(title) ⇒ Object



18
19
20
# File 'lib/article.rb', line 18

def self.find_by_title(title)
  all.detect{|story| story.title == title}
end


30
31
32
# File 'lib/article.rb', line 30

def self.popular
  all.select{|a| a.popular}
end

.sharedObject



34
35
36
# File 'lib/article.rb', line 34

def self.shared
  all.select{|a| a.shared}
end

Instance Method Details



22
23
24
# File 'lib/article.rb', line 22

def add_to_popular
  @popular = true
end

#add_to_sharedObject



26
27
28
# File 'lib/article.rb', line 26

def add_to_shared
  @shared = true
end

#assign_attributes(attribute_hash) ⇒ Object



14
15
16
# File 'lib/article.rb', line 14

def assign_attributes(attribute_hash)
  attribute_hash.each{|k, v| self.send("#{k}=", v)}
end