Class: Taxonifi::Model::AuthorYear

Inherits:
Base
  • Object
show all
Defined in:
lib/taxonifi/model/author_year.rb

Overview

A class to aggregate People and Year combinations.

Constant Summary

Constants inherited from Base

Base::ATTRIBUTES

Instance Attribute Summary collapse

Attributes inherited from Base

#id, #properties, #row_number

Instance Method Summary collapse

Methods inherited from Base

#add_properties, #add_property, #ancestor_ids, #ancestors, #build, #delete_property, #replace_property

Methods included from SharedClassMethods

included

Constructor Details

#initialize(options = {}) ⇒ AuthorYear

Returns a new instance of AuthorYear.



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/taxonifi/model/author_year.rb', line 15

def initialize(options = {})
  opts = {
    :people => [],
    :parens => false,
    :year => nil
  }.merge!(options)

  @parens = opts[:parens] 
  @people = opts[:people] 
  @year = opts[:year] 
end

Instance Attribute Details

#parensObject

The parens attribute reflects that this combinations was cited in parentheses.



13
14
15
# File 'lib/taxonifi/model/author_year.rb', line 13

def parens
  @parens
end

#peopleObject

Array of Taxonifi::Model::People



8
9
10
# File 'lib/taxonifi/model/author_year.rb', line 8

def people
  @people
end

#yearObject

String



10
11
12
# File 'lib/taxonifi/model/author_year.rb', line 10

def year
  @year
end

Instance Method Details

#compact_indexObject

Return a string representing all data, used in indexing.



28
29
30
31
32
33
34
# File 'lib/taxonifi/model/author_year.rb', line 28

def compact_index
  index = [@year]
  @people.each do |a|
    index.push(a.compact_string)
  end
  index.join("-")
end