Class: References::Reference
- Inherits:
-
Object
- Object
- References::Reference
- Includes:
- Comparable
- Defined in:
- lib/references/reference.rb
Overview
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: end
Instance Attribute Summary collapse
-
#authors ⇒ Object
Returns the value of attribute authors.
-
#datee ⇒ Object
Returns the value of attribute datee.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Define the method to compare several Reference objects.
-
#author(hash) ⇒ Object
Let, set a author/s in a Reference.
-
#cantidadAuthors ⇒ Object
Cuantity of authors set.
- #cantidadIsbn ⇒ Object
- #cantidadSeries ⇒ Object
-
#date(date) ⇒ Object
A Reference only can have a date.
-
#editorial(editorial) ⇒ Object
A Reference only can have a editorial.
-
#formatAPA ⇒ Object
Not specification in the Reference abstract class.
- #hasDate ⇒ Object
- #hasEdition ⇒ Object
- #hasEditionnumber ⇒ Object
-
#hasTitle ⇒ Object
Is have set a title?.
-
#initialize(&block) ⇒ Reference
constructor
Take a block.
-
#prettyOutput(array) ⇒ Object
This function let format a array to prettitied its output adding a ‘&’ before to last element.
-
#title(title) ⇒ Object
A Reference only can have a title.
Constructor Details
#initialize(&block) ⇒ Reference
Take a block
30 31 32 |
# File 'lib/references/reference.rb', line 30 def initialize(&block) instance_eval &block end |
Instance Attribute Details
#authors ⇒ Object
Returns the value of attribute authors.
28 29 30 |
# File 'lib/references/reference.rb', line 28 def @authors end |
#datee ⇒ Object
Returns the value of attribute datee.
28 29 30 |
# File 'lib/references/reference.rb', line 28 def datee @datee end |
Instance Method Details
#<=>(other) ⇒ Object
Define the method to compare several Reference objects
79 80 81 82 83 84 85 |
# File 'lib/references/reference.rb', line 79 def <=>(other) int = other. <=> @authors if int = 0 int = other.datee <=> @datee end int end |
#author(hash) ⇒ Object
Let, set a author/s in a Reference. You can define some authors, only calling this n-repeated times
36 37 38 39 40 41 |
# File 'lib/references/reference.rb', line 36 def (hash) if @authors.nil? @authors = [] end @authors << References::Name.new(hash[:surnames], hash[:names]) end |
#cantidadAuthors ⇒ Object
Cuantity of authors set
88 89 90 |
# File 'lib/references/reference.rb', line 88 def cantidadAuthors() @authors.length() end |
#cantidadIsbn ⇒ Object
133 134 135 |
# File 'lib/references/reference.rb', line 133 def cantidadIsbn @isbn.length end |
#cantidadSeries ⇒ Object
101 102 103 104 105 106 107 |
# File 'lib/references/reference.rb', line 101 def cantidadSeries if @serie!= nil then 1 else 0 end end |
#date(date) ⇒ Object
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
61 62 63 |
# File 'lib/references/reference.rb', line 61 def date(date) @datee = Date.new(date[:year],date[:month],date[:day]) end |
#editorial(editorial) ⇒ Object
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
52 53 54 55 56 |
# File 'lib/references/reference.rb', line 52 def editorial(editorial) @serie = editorial[:serie] @edition = editorial[:edition] @editionnumber = editorial[:editionnumber] end |
#formatAPA ⇒ Object
Not specification in the Reference abstract class
138 139 140 |
# File 'lib/references/reference.rb', line 138 def formatAPA "Not format abstract class" end |
#hasDate ⇒ Object
125 126 127 128 129 130 131 |
# File 'lib/references/reference.rb', line 125 def hasDate if @datee then true else false end end |
#hasEdition ⇒ Object
109 110 111 112 113 114 115 |
# File 'lib/references/reference.rb', line 109 def hasEdition if @edition then true else false end end |
#hasEditionnumber ⇒ Object
117 118 119 120 121 122 123 |
# File 'lib/references/reference.rb', line 117 def hasEditionnumber if @editionnumber then true else false end end |
#hasTitle ⇒ Object
Is have set a title?
93 94 95 96 97 98 99 |
# File 'lib/references/reference.rb', line 93 def hasTitle if @title then true else false end end |
#prettyOutput(array) ⇒ Object
This function let format a array to prettitied its output adding a ‘&’ before to last element.
68 69 70 71 72 73 74 75 76 |
# 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 |
#title(title) ⇒ Object
A Reference only can have a title. If you call this function twice times this, overwrite the las value
45 46 47 |
# File 'lib/references/reference.rb', line 45 def title(title) @title = title end |