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

authors[RW]
datee[RW]

Public Class Methods

new(&block) click to toggle source

Take a block

# File lib/references/reference.rb, line 30
def initialize(&block)
  instance_eval &block
end

Public Instance Methods

<=>(other) click to toggle source

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
author(hash) click to toggle source

Let, set a author/s in a Reference. You can define some authors, only calling this n-repeated times @param hash [String]

# File lib/references/reference.rb, line 36
def author(hash)
  if @authors.nil?
    @authors = []
  end
  @authors << References::Name.new(hash[:surnames], hash[:names])
end
cantidadAuthors() click to toggle source

Cuantity of authors set

# File lib/references/reference.rb, line 88
def cantidadAuthors()
  @authors.length()
end
cantidadIsbn() click to toggle source
# File lib/references/reference.rb, line 133
def cantidadIsbn
  @isbn.length
end
cantidadSeries() click to toggle source
# File lib/references/reference.rb, line 101
def cantidadSeries
  if @serie!= nil then
    1
  else
    0
  end
end
date(date) click to toggle source

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
editorial(editorial) click to toggle source

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
formatAPA() click to toggle source

Not specification in the Reference abstract class

# File lib/references/reference.rb, line 138
def formatAPA
  "Not format abstract class"
end
hasDate() click to toggle source
# File lib/references/reference.rb, line 125
def hasDate
  if @datee then
    true
  else
    false
  end
end
hasEdition() click to toggle source
# File lib/references/reference.rb, line 109
def hasEdition
  if @edition then
    true
  else
    false
  end
end
hasEditionnumber() click to toggle source
# File lib/references/reference.rb, line 117
def hasEditionnumber
  if @editionnumber then
    true
  else
    false
  end
end
hasTitle() click to toggle source

Is have set a title?

# File lib/references/reference.rb, line 93
def hasTitle
  if @title then
    true
  else
    false
  end
end
prettyOutput(array) click to toggle source

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
title(title) click to toggle source

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