Class: Taxonifi::Model::Ref
Overview
A basic reference object.
Constant Summary collapse
- ATTRIBUTES =
These attributes are set automatically on #new()
[ :authors, :title, :year, :publication, :volume, :number, :pages, :pg_start, :pg_end, :cited_page, :full_citation ]
Instance Attribute Summary collapse
-
#author_year_index ⇒ Object
Return a Taxonifi::Model::AuthorYear representing author/year !! Identical to method in Taxonifi::Model::Name !! Not necessarily unique.
-
#authors ⇒ Object
Array of Taxonifi::Model::Person.
-
#cited_page ⇒ Object
String.
-
#full_citation ⇒ Object
String.
-
#number ⇒ Object
String.
-
#pages ⇒ Object
String.
-
#pg_end ⇒ Object
String.
-
#pg_start ⇒ Object
String.
-
#publication ⇒ Object
String.
-
#title ⇒ Object
String.
-
#volume ⇒ Object
String.
-
#year ⇒ Object
String.
Attributes inherited from Base
Instance Method Summary collapse
- #add_author_year(string) ⇒ Object
-
#compact_string ⇒ Object
Returns a pipe delimited representation of the reference.
-
#generate_author_year_index ⇒ Object
(Re-) generate the author year index.
-
#initialize(options = {}) ⇒ Ref
constructor
If :author_year is passed it is broken down into People + year.
-
#page_string ⇒ Object
Return a single String value representing the page data available for this reference.
Methods inherited from Base
#add_properties, #add_property, #ancestor_ids, #ancestors, #build, #delete_property, #replace_property
Methods included from SharedClassMethods
Constructor Details
#initialize(options = {}) ⇒ Ref
If :author_year is passed it is broken down into People + year.
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/taxonifi/model/ref.rb', line 50 def initialize( = {}) super opts = { }.merge!() @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?) (opts[:author_year]) if !opts[:author_year].nil? && opts[:author_year].size > 0 true end |
Instance Attribute Details
#author_year_index ⇒ Object
Return a Taxonifi::Model::AuthorYear representing author/year !! Identical to method in Taxonifi::Model::Name !! Not necessarily unique.
47 48 49 |
# File 'lib/taxonifi/model/ref.rb', line 47 def @author_year_index end |
#authors ⇒ Object
Array of Taxonifi::Model::Person
24 25 26 |
# File 'lib/taxonifi/model/ref.rb', line 24 def @authors end |
#cited_page ⇒ Object
String. Some specific page(s) of note.
42 43 44 |
# File 'lib/taxonifi/model/ref.rb', line 42 def cited_page @cited_page end |
#full_citation ⇒ Object
String. The full text of the citation, as read from input or assigned, not computed from individual components.
44 45 46 |
# File 'lib/taxonifi/model/ref.rb', line 44 def full_citation @full_citation end |
#number ⇒ Object
String
34 35 36 |
# File 'lib/taxonifi/model/ref.rb', line 34 def number @number end |
#pages ⇒ Object
String. Anything that doesn’t fit in a page range.
36 37 38 |
# File 'lib/taxonifi/model/ref.rb', line 36 def pages @pages end |
#pg_end ⇒ Object
String
40 41 42 |
# File 'lib/taxonifi/model/ref.rb', line 40 def pg_end @pg_end end |
#pg_start ⇒ Object
String
38 39 40 |
# File 'lib/taxonifi/model/ref.rb', line 38 def pg_start @pg_start end |
#publication ⇒ Object
String
30 31 32 |
# File 'lib/taxonifi/model/ref.rb', line 30 def publication @publication end |
#title ⇒ Object
String
26 27 28 |
# File 'lib/taxonifi/model/ref.rb', line 26 def title @title end |
#volume ⇒ Object
String
32 33 34 |
# File 'lib/taxonifi/model/ref.rb', line 32 def volume @volume end |
#year ⇒ Object
String
28 29 30 |
# File 'lib/taxonifi/model/ref.rb', line 28 def year @year end |
Instance Method Details
#add_author_year(string) ⇒ Object
62 63 64 65 66 |
# File 'lib/taxonifi/model/ref.rb', line 62 def (string) auth_yr = Taxonifi::Splitter::Builder.(string) @year = auth_yr.year @authors = auth_yr.people end |
#compact_string ⇒ Object
Returns a pipe delimited representation of the reference.
69 70 71 72 |
# File 'lib/taxonifi/model/ref.rb', line 69 def compact_string s = [.collect{|a| a.compact_string}.join, year, self.title, publication, volume, number, pages, pg_start, pg_end, cited_page].join("|").downcase.gsub(/\s/, '') s end |
#generate_author_year_index ⇒ Object
(Re-) generate the author year index.
82 83 84 |
# File 'lib/taxonifi/model/ref.rb', line 82 def @author_year_index = Taxonifi::Model::AuthorYear.new(people: @authors, year: @year).compact_index end |
#page_string ⇒ Object
Return a single String value representing the page data available for this reference.
88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/taxonifi/model/ref.rb', line 88 def page_string str = '' if @pg_start.nil? str = [@pages].compact.join else if @pg_end.nil? str = [@pg_start, @pages].compact.join("; ") else str = ["#{@pg_start}-#{@pg_end}", @pages].compact.join("; ") end end str.strip end |