Module: HistoricalDating::Api

Included in:
HistoricalDating
Defined in:
lib/historical_dating/api.rb

Instance Method Summary collapse

Instance Method Details

#parse(string, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/historical_dating/api.rb', line 6

def parse(string, options = {})
  options = {
    locale: 'de'
  }.merge(options)

  unless options[:locale] == 'de'
    raise HistoricalDating::Error.new('locale_not_supported', locale: options[:locale])
  end

  result = parser.transform(string)
  HistoricalDating::Range.new(result[:from], result[:to])
end

#parserObject



2
3
4
# File 'lib/historical_dating/api.rb', line 2

def parser
  @parser ||= HistoricalDating::Parser.new
end