class NameSpotter::ScientificName
Attributes
end_pos[R]
scientific[R]
score[R]
start_pos[R]
verbatim[R]
Public Class Methods
new(verbatim_name, options={})
click to toggle source
# File lib/name-spotter/scientific_name.rb, line 10 def initialize(verbatim_name, options={}) @verbatim = verbatim_name if options[:start_position] @start_pos = options[:start_position] @end_pos = @start_pos + @verbatim.length - 1 end @score = options[:score] if options[:score] @scientific = options[:scientific_name] if options[:scientific_name] end
normalize(name)
click to toggle source
# File lib/name-spotter/scientific_name.rb, line 5 def self.normalize(name) name = name.gsub(",", " ") name = name.gsub(/\s+/, " ") end
Public Instance Methods
eql?(other_name)
click to toggle source
Use this in specs
# File lib/name-spotter/scientific_name.rb, line 21 def eql?(other_name) other_name.is_a?(Name) && other_name.verbatim.eql?(verbatim) && other_name.scientific.eql?(scientific) && other_name.start_pos.eql?(start_pos) && other_name.end_pos.eql?(end_pos) && other_name.score.eql?(score) end
to_hash()
click to toggle source
# File lib/name-spotter/scientific_name.rb, line 30 def to_hash name_hash = {:verbatim => verbatim} name_hash[:scientificName] = scientific if scientific name_hash[:offsetStart] = start_pos if start_pos name_hash[:offsetEnd] = end_pos if end_pos name_hash end