class References::Reference
Represent references to resources in a document, it can be e-documents papers, book and also magazines. To create a Reference you need know the DSL to make, is so simple: @example
@libro = References::Book.new do author :surnames => "Thomas", :names => "Dave" author :surnames => "Hunt", :names => "Andy" author :surnames => "Chad", :names => "Fowler" title "Programming Ruby 1.9 & 2.0" subtitle "The Pragmatic Programmers’ Guide" editorial :serie => "The Facets of Ruby", :edition => "Pragmatic Bookshelf", :editionnumber => 4 date :year => 2013, :month => 7, :day => 7 isbn "ISBN-13: 978-1937785499" isbn "ISBN-10: 1937785491"
end
Attributes
Public Class Methods
Take a block
# File lib/references/reference.rb, line 30 def initialize(&block) instance_eval &block end
Public Instance Methods
Define the method to compare several Reference
objects
# File lib/references/reference.rb, line 79 def <=>(other) int = other.authors <=> @authors if int = 0 int = other.datee <=> @datee end int end
Cuantity of authors set
# File lib/references/reference.rb, line 88 def cantidadAuthors() @authors.length() end
# File lib/references/reference.rb, line 133 def cantidadIsbn @isbn.length end
# File lib/references/reference.rb, line 101 def cantidadSeries if @serie!= nil then 1 else 0 end end
A Reference
only can have a date. If you call this function twice times, this overwrite the las value The hash must have a :year => Number, :month => Number, :day => Number @param date [Hash]
# File lib/references/reference.rb, line 61 def date(date) @datee = Date.new(date[:year],date[:month],date[:day]) end
A Reference
only can have a editorial. If you call this function twice times, this overwrite the las value The hash must have a :serie => String, :edition => String, :editionnumber => Number @param editorial [Hash]
# File lib/references/reference.rb, line 52 def editorial(editorial) @serie = editorial[:serie] @edition = editorial[:edition] @editionnumber = editorial[:editionnumber] end
Not specification in the Reference
abstract class
# File lib/references/reference.rb, line 138 def formatAPA "Not format abstract class" end
# File lib/references/reference.rb, line 125 def hasDate if @datee then true else false end end
# File lib/references/reference.rb, line 109 def hasEdition if @edition then true else false end end
# File lib/references/reference.rb, line 117 def hasEditionnumber if @editionnumber then true else false end end
Is have set a title?
# File lib/references/reference.rb, line 93 def hasTitle if @title then true else false end end
This function let format a array to prettitied its output adding a ‘&’ before to last element. @param array [List] @return String
# File lib/references/reference.rb, line 68 def prettyOutput(array) if array.length > 1 array[0..-2].join("") + " & " + array[-1] elsif array.length == 1 array[0] else "" end end
A Reference
only can have a title. If you call this function twice times this, overwrite the las value @param title [String]
# File lib/references/reference.rb, line 45 def title(title) @title = title end