Class: ChildrensBooks::Book
- Inherits:
-
Object
- Object
- ChildrensBooks::Book
- Defined in:
- lib/childrens_books/book.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#age ⇒ Object
Returns the value of attribute age.
-
#author ⇒ Object
Returns the value of attribute author.
-
#description ⇒ Object
Returns the value of attribute description.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
-
#year ⇒ Object
Returns the value of attribute year.
Class Method Summary collapse
- .all ⇒ Object
- .bigkidbooks ⇒ Object
- .littlekidbooks ⇒ Object
- .preschoolbooks ⇒ Object
- .tweenbooks ⇒ Object
Instance Method Summary collapse
-
#initialize(title, author, description, age, year, url) ⇒ Book
constructor
A new instance of Book.
Constructor Details
#initialize(title, author, description, age, year, url) ⇒ Book
Returns a new instance of Book.
6 7 8 9 10 11 12 13 14 |
# File 'lib/childrens_books/book.rb', line 6 def initialize(title, , description, age, year, url) @title = title @author = @description = description @age = age @year = year @url = url @@all << self end |
Instance Attribute Details
#age ⇒ Object
Returns the value of attribute age.
3 4 5 |
# File 'lib/childrens_books/book.rb', line 3 def age @age end |
#author ⇒ Object
Returns the value of attribute author.
3 4 5 |
# File 'lib/childrens_books/book.rb', line 3 def @author end |
#description ⇒ Object
Returns the value of attribute description.
3 4 5 |
# File 'lib/childrens_books/book.rb', line 3 def description @description end |
#title ⇒ Object
Returns the value of attribute title.
3 4 5 |
# File 'lib/childrens_books/book.rb', line 3 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/childrens_books/book.rb', line 3 def url @url end |
#year ⇒ Object
Returns the value of attribute year.
3 4 5 |
# File 'lib/childrens_books/book.rb', line 3 def year @year end |
Class Method Details
.all ⇒ Object
16 17 18 |
# File 'lib/childrens_books/book.rb', line 16 def self.all @@all end |
.bigkidbooks ⇒ Object
32 33 34 35 36 |
# File 'lib/childrens_books/book.rb', line 32 def self.bigkidbooks self.all.select do |book| book if (8..9).to_a.include?(book.age.to_i) end end |
.littlekidbooks ⇒ Object
26 27 28 29 30 |
# File 'lib/childrens_books/book.rb', line 26 def self.littlekidbooks self.all.select do |book| book if (5..7).to_a.include?(book.age.to_i) end end |
.preschoolbooks ⇒ Object
20 21 22 23 24 |
# File 'lib/childrens_books/book.rb', line 20 def self.preschoolbooks self.all.select do |book| book if (2..4).to_a.include?(book.age.to_i) end end |
.tweenbooks ⇒ Object
38 39 40 41 42 |
# File 'lib/childrens_books/book.rb', line 38 def self.tweenbooks self.all.select do |book| book if (10..12).to_a.include?(book.age.to_i) end end |