Class: Taxonifi::Splitter::Tokens::Quadrinomial
- Defined in:
- lib/taxonifi/splitter/tokens.rb
Overview
A token to match quadrinomial.s Matches: Foo Foo (Bar) Foo (Bar) stuff Foo (Bar) stuff things Foo stuff Foo stuff things TODO: This will likley erroroneously match on authors names that are uncapitalized, e.g.:
Foo stuff von Helsing, 1920
Instance Attribute Summary collapse
-
#genus ⇒ Object
readonly
Returns the value of attribute genus.
-
#species ⇒ Object
readonly
Returns the value of attribute species.
-
#subgenus ⇒ Object
readonly
Returns the value of attribute subgenus.
-
#subspecies ⇒ Object
readonly
Returns the value of attribute subspecies.
Attributes inherited from Token
Instance Method Summary collapse
-
#initialize(str) ⇒ Quadrinomial
constructor
A new instance of Quadrinomial.
Constructor Details
#initialize(str) ⇒ Quadrinomial
Returns a new instance of Quadrinomial.
291 292 293 294 295 296 297 298 299 300 301 302 |
# File 'lib/taxonifi/splitter/tokens.rb', line 291 def initialize(str) str.strip str =~ /\A\s*([A-Z][^\s]+\w)\s*(\([A-Z][a-z]+\))?\s?([a-z][^\s]+(?!\.))?\s?([a-z][^\s]*(?!\.)\b)?\s*/i @genus = $1 @subgenus = $2 @species = $3 @subspecies = $4 if @subgenus =~ /\((.*)\)/ @subgenus = $1 end end |
Instance Attribute Details
#genus ⇒ Object (readonly)
Returns the value of attribute genus.
286 287 288 |
# File 'lib/taxonifi/splitter/tokens.rb', line 286 def genus @genus end |
#species ⇒ Object (readonly)
Returns the value of attribute species.
286 287 288 |
# File 'lib/taxonifi/splitter/tokens.rb', line 286 def species @species end |
#subgenus ⇒ Object (readonly)
Returns the value of attribute subgenus.
286 287 288 |
# File 'lib/taxonifi/splitter/tokens.rb', line 286 def subgenus @subgenus end |
#subspecies ⇒ Object (readonly)
Returns the value of attribute subspecies.
286 287 288 |
# File 'lib/taxonifi/splitter/tokens.rb', line 286 def subspecies @subspecies end |