Class: NYTBestsellers::Genre
- Inherits:
-
Object
- Object
- NYTBestsellers::Genre
- Defined in:
- lib/nytimes/genre.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #books ⇒ Object
-
#initialize(hash = {}) ⇒ Genre
constructor
A new instance of Genre.
Constructor Details
#initialize(hash = {}) ⇒ Genre
Returns a new instance of Genre.
6 7 8 9 10 11 12 |
# File 'lib/nytimes/genre.rb', line 6 def initialize(hash = {}) hash.each do |key, value| self.send("#{key}=", value) end @@all << self @books = [] end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/nytimes/genre.rb', line 3 def name @name end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/nytimes/genre.rb', line 3 def url @url end |
Class Method Details
.all ⇒ Object
14 15 16 |
# File 'lib/nytimes/genre.rb', line 14 def self.all @@all end |
.find_by_name(genre_name) ⇒ Object
22 23 24 |
# File 'lib/nytimes/genre.rb', line 22 def self.find_by_name(genre_name) self.all.find {|x| x.name == genre_name} end |
.find_by_num(num_input) ⇒ Object
26 27 28 |
# File 'lib/nytimes/genre.rb', line 26 def self.find_by_num(num_input) self.all[num_input.to_i-1] end |
Instance Method Details
#books ⇒ Object
18 19 20 |
# File 'lib/nytimes/genre.rb', line 18 def books @books end |