Class: ChildrensBooks::Book

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

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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, author, description, age, year, url)
    @title = title
    @author = author
    @description = description
    @age = age
    @year = year
    @url = url
    @@all << self
end

Instance Attribute Details

#ageObject

Returns the value of attribute age.



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

def age
  @age
end

#authorObject

Returns the value of attribute author.



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

def author
  @author
end

#descriptionObject

Returns the value of attribute description.



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

def description
  @description
end

#titleObject

Returns the value of attribute title.



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

def title
  @title
end

#urlObject

Returns the value of attribute url.



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

def url
  @url
end

#yearObject

Returns the value of attribute year.



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

def year
  @year
end

Class Method Details

.allObject



16
17
18
# File 'lib/childrens_books/book.rb', line 16

def self.all
    @@all
end

.bigkidbooksObject



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

.littlekidbooksObject



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

.preschoolbooksObject



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

.tweenbooksObject



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