Class: Reference

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/prct11/reference.rb

Direct Known Subclasses

Book, Regularpublications

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(authors, title, date) ⇒ Reference

Returns a new instance of Reference.



6
7
8
9
10
11
12
13
# File 'lib/prct11/reference.rb', line 6

def initialize(authors, title, date)
    self.authors = []
    authors.each do |palabras|
       	@authors.push(palabras)
    end
        @title = title
        @date = date
end

Instance Attribute Details

#authorsObject

Returns the value of attribute authors.



3
4
5
# File 'lib/prct11/reference.rb', line 3

def authors
  @authors
end

#dateObject

Returns the value of attribute date.



3
4
5
# File 'lib/prct11/reference.rb', line 3

def date
  @date
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/prct11/reference.rb', line 3

def title
  @title
end

Instance Method Details

#<=>(other) ⇒ Object



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

def <=>(other)
     return nil unless other.is_a? Reference
     if authors == other.authors then
     	if date == other.date
     		title <=> other.title
     	else 
     		date <=> other.date
     	end
     else
     	authors <=> other.authors
     end
end

#get_titleObject



15
16
17
# File 'lib/prct11/reference.rb', line 15

def get_title
	@title
end