Sha256: 6f171fba91fc9044cf57419104d140997260cd107fca2748e7df506272d73906

Contents?: true

Size: 762 Bytes

Versions: 2

Compression:

Stored size: 762 Bytes

Contents

# frozen_string_literal: true

require_relative 'parser/gnparser'

module Biodiversity
  # Parser provides a namespace for functions to parse scientific names.
  module Parser
    @compact_gnparser = {
      false => GnParser::Compact.new,
      true => GnParser::Compact.new('--cultivar')
    }
    @csv_gnparser = {
      false => GnParser::Csv.new,
      true => GnParser::Csv.new('--cultivar')
    }

    def self.parse(name, simple: false, with_cultivars: false)
      (simple ? @csv_gnparser[!!with_cultivars] : @compact_gnparser[!!with_cultivars]).parse(name)
    end

    def self.parse_ary(ary, simple: false, with_cultivars: false)
      (simple ? @csv_gnparser[!!with_cultivars] : @compact_gnparser[!!with_cultivars]).parse_ary(ary)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
biodiversity-6.0.1 lib/biodiversity/parser.rb
biodiversity-6.0.0 lib/biodiversity/parser.rb