Class: DSLBook

Inherits:
Book show all
Defined in:
lib/prct11/DSL.rb,
lib/prct11/prueba.rb

Instance Attribute Summary

Attributes inherited from Book

#authors, #edition, #editorial, #isbn, #volume

Attributes inherited from Reference

#authors, #date

Instance Method Summary collapse

Methods inherited from Book

#to_s

Methods inherited from Reference

#<=>, #get_title

Constructor Details

#initialize(block) ⇒ DSLBook

Returns a new instance of DSLBook.



16
17
18
19
20
21
22
23
24
25
# File 'lib/prct11/DSL.rb', line 16

def initialize(&block)
    self.title = []
    self.editorial = []
    self.edition = []
    self.date = []
    self.isbn =[]
    self.authors = []
    self.volume = []
    instance_eval(&block)     
end

Instance Method Details

#author(author) ⇒ Object



31
32
33
# File 'lib/prct11/DSL.rb', line 31

def author(author)
    self.authors = author
end

#book(book) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/prct11/DSL.rb', line 35

def book (datos = {})
   self.title = datos[:nombre]
   self.editorial = datos[:editorial]
   self.edition = datos[:edicion]
   self.date = datos[:fecha]
   self.isbn = datos[:isbn]
   self.volume = datos[:volumen]
end

#title(title) ⇒ Object



27
28
29
# File 'lib/prct11/DSL.rb', line 27

def title(title)
    self.title = title
end