Class: Taxonifi::Splitter::Tokens::AuthorYear
- Defined in:
- lib/taxonifi/splitter/tokens.rb
Overview
A token to match an author year combination, breaks the string into three parts.
Instance Attribute Summary collapse
-
#authors ⇒ Object
readonly
Returns the value of attribute authors.
-
#parens ⇒ Object
readonly
Returns the value of attribute parens.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Attributes inherited from Token
Instance Method Summary collapse
-
#initialize(str) ⇒ AuthorYear
constructor
A new instance of AuthorYear.
Constructor Details
#initialize(str) ⇒ AuthorYear
Returns a new instance of AuthorYear.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/taxonifi/splitter/tokens.rb', line 44 def initialize(str) str.strip! # check for parens if str =~ /\((.*)\)/ w = $1 @parens = true else w = str @parens = false end # check for year if w =~ /(\d\d\d\d)\Z/ @year = $1.to_i w.gsub!(/\d\d\d\d\Z/, "") w.strip! end w.gsub!(/,\s*\Z/, '') @authors = w.strip true end |
Instance Attribute Details
#authors ⇒ Object (readonly)
Returns the value of attribute authors.
39 40 41 |
# File 'lib/taxonifi/splitter/tokens.rb', line 39 def @authors end |
#parens ⇒ Object (readonly)
Returns the value of attribute parens.
39 40 41 |
# File 'lib/taxonifi/splitter/tokens.rb', line 39 def parens @parens end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
39 40 41 |
# File 'lib/taxonifi/splitter/tokens.rb', line 39 def year @year end |