Class: Book

Inherits:
Reference show all
Defined in:
lib/prct11/book.rb

Direct Known Subclasses

DSLBook

Instance Attribute Summary collapse

Attributes inherited from Reference

#date, #title

Instance Method Summary collapse

Methods inherited from Reference

#<=>, #get_title

Constructor Details

#initialize(title, editorial, edition, date, isbn, authors, volume) ⇒ Book

Returns a new instance of Book.



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/prct11/book.rb', line 6

def initialize(title,editorial,edition,date,isbn,authors, volume)
  super(authors,title,date)
  @authors = authors
       @volume = volume
       @editorial = editorial
       @edition = edition

       self.isbn = []
       isbn.each do |numeros|
           @isbn.push(numeros)
       end
       return self
end

Instance Attribute Details

#authorsObject

Returns the value of attribute authors.



4
5
6
# File 'lib/prct11/book.rb', line 4

def authors
  @authors
end

#editionObject

Returns the value of attribute edition.



4
5
6
# File 'lib/prct11/book.rb', line 4

def edition
  @edition
end

#editorialObject

Returns the value of attribute editorial.



4
5
6
# File 'lib/prct11/book.rb', line 4

def editorial
  @editorial
end

#isbnObject

Returns the value of attribute isbn.



4
5
6
# File 'lib/prct11/book.rb', line 4

def isbn
  @isbn
end

#volumeObject

Returns the value of attribute volume.



4
5
6
# File 'lib/prct11/book.rb', line 4

def volume
  @volume
end

Instance Method Details

#to_sObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/prct11/book.rb', line 20

def to_s
    text=""
  
    for i in (0..@authors.size-2)
       text << "#{authors[i]} , " 
    end
    text << "#{authors[authors.size-1]}."
    text << "\n#{@title}."
   text << "\n#{@volume}."
     text << "\n#{@editorial}; #{@edition} Edition (#{@date})."
    for i in (0..@isbn.size-1)
       text << "\nISBN #{@isbn[i].length}: #{@isbn[i]}."
    end
    text
end