Class: Taxonifi::Splitter::Tokens::Quadrinomial

Inherits:
Token
  • Object
show all
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

Attributes inherited from Token

#flag, #value

Instance Method Summary collapse

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

#genusObject (readonly)

Returns the value of attribute genus.



286
287
288
# File 'lib/taxonifi/splitter/tokens.rb', line 286

def genus
  @genus
end

#speciesObject (readonly)

Returns the value of attribute species.



286
287
288
# File 'lib/taxonifi/splitter/tokens.rb', line 286

def species
  @species
end

#subgenusObject (readonly)

Returns the value of attribute subgenus.



286
287
288
# File 'lib/taxonifi/splitter/tokens.rb', line 286

def subgenus
  @subgenus
end

#subspeciesObject (readonly)

Returns the value of attribute subspecies.



286
287
288
# File 'lib/taxonifi/splitter/tokens.rb', line 286

def subspecies
  @subspecies
end