class Taxonifi::Model::Ref

A basic reference object.

Constants

ATTRIBUTES

These attributes are set automatically on new()

Attributes

author_year_index[RW]

String. Computed index based on existing #authors and #year

authors[RW]
cited_page[RW]

String. Some specific page(s) of note.

full_citation[RW]

String. The full text of the citation, as read from input or assigned, not computed from individual components.

number[RW]

String

pages[RW]

String. Anything that doesn’t fit in a page range.

pg_end[RW]

String

pg_start[RW]

String

publication[RW]

String

title[RW]

String

volume[RW]

String

year[RW]

String

Public Class Methods

new(options = {}) click to toggle source

If :author_year is passed it is broken down into People + year.

# File lib/models/ref.rb, line 50
def initialize(options = {})
  opts = {
  }.merge!(options)
  @parent = nil
  build(ATTRIBUTES, opts)
  @authors = [] if @authors.nil?
  raise Taxonifi::RefError, 'If :author_year is provided then authors and year must not be.' if opts[:author_year] && (!opts[:year].nil? || !opts[:authors].nil?)
  add_author_year(opts[:author_year]) if !opts[:author_year].nil? && opts[:author_year].size > 0
  true
end

Public Instance Methods

add_author_year(string) click to toggle source
# File lib/models/ref.rb, line 61
def add_author_year(string)
  auth_yr = Taxonifi::Splitter::Builder.build_author_year(string)
  @year = auth_yr.year
  @authors = auth_yr.people
end
compact_string() click to toggle source

Returns a pipe delimited representation of the reference.

# File lib/models/ref.rb, line 68
def compact_string
  s = [authors.collect{|a| a.compact_string}.join, year, self.title, publication, volume, number, pages, pg_start, pg_end, cited_page].join("|").downcase.gsub(%r\s/, '')
  s
end
generate_author_year_index() click to toggle source

(re-) generate the author year index.

# File lib/models/ref.rb, line 79
def generate_author_year_index
  @author_year_index = Taxonifi::Model::AuthorYear.new(people: @authors, year: @year).compact_index
end