Class: Biblioref

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/dsl/references.rb

Direct Known Subclasses

Book, EBook, EDoc, Newspaper

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Biblioref

Returns a new instance of Biblioref.



13
14
15
16
17
# File 'lib/dsl/references.rb', line 13

def initialize(params = {})
self.author_name = []
self.author_surname = []
      
end

Instance Attribute Details

#author_nameObject

Nombres de autores



5
6
7
# File 'lib/dsl/references.rb', line 5

def author_name
  @author_name
end

#author_surnameObject

Apellidos de autores



6
7
8
# File 'lib/dsl/references.rb', line 6

def author_surname
  @author_surname
end

#edit_numObject

Numero de edición



10
11
12
# File 'lib/dsl/references.rb', line 10

def edit_num
  @edit_num
end

#p_dateObject

Fecha de publicación



11
12
13
# File 'lib/dsl/references.rb', line 11

def p_date
  @p_date
end

#p_houseObject

Casa editorial



8
9
10
# File 'lib/dsl/references.rb', line 8

def p_house
  @p_house
end

#p_placeObject

Lugar de publicación



9
10
11
# File 'lib/dsl/references.rb', line 9

def p_place
  @p_place
end

#title_Object

Título de publicación



7
8
9
# File 'lib/dsl/references.rb', line 7

def title_
  @title_
end

#volumeObject

Volumen



12
13
14
# File 'lib/dsl/references.rb', line 12

def volume
  @volume
end

Instance Method Details

#<=>(another) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/dsl/references.rb', line 33

def <=> (another)
   if (self.author_surname != another.author_surname)
  self.author_surname<=>another.author_surname
  elsif (self.author_surname == another.author_surname && self.p_date!=another.p_date)
self.author_surname<=>another.author_surname
self.p_date<=>another.p_date
  end
end

#to_sObject



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/dsl/references.rb', line 19

def to_s
      fullnames = ""
      i=0
  while i < self.author_name.count
if i != self.author_name.count-1
  fullnames= fullnames + "#{self.author_surname[i]}, #{self.author_name[i][0]}. & "
else
  fullnames= fullnames + "#{self.author_surname[i]}, #{self.author_name[i][0]}."
end
  i=i+1
end
  "#{fullnames} (#{self.p_date}). #{self.title_} (#{self.edit_num}) (#{self.volume}). #{self.p_place}: #{self.p_house}."
end