Class: ParsleyStore

Inherits:
Object
  • Object
show all
Defined in:
lib/parsley-store.rb,
lib/parsley-store/version.rb

Constant Summary collapse

LOCAL =

database numbers for Redis

1
SLAVE =
2
VERSION =
"0.3.6"

Instance Method Summary collapse

Constructor Details

#initialize(local_db = LOCAL, slave_db = SLAVE, opts = {}) ⇒ ParsleyStore

Returns a new instance of ParsleyStore.


14
15
16
17
18
19
# File 'lib/parsley-store.rb', line 14

def initialize(local_db = LOCAL, slave_db = SLAVE, opts = {})
  redis_host = opts[:redis_host] || "0.0.0.0"
  @parser = ScientificNameParser.new
  @local = Redis.new(host: redis_host)
  @local.select(local_db)
end

Instance Method Details

#parse(scientific_name, opts = {}) ⇒ Object


21
22
23
24
25
26
27
28
29
# File 'lib/parsley-store.rb', line 21

def parse(scientific_name, opts = {})
  @canonical_only = !!opts[:canonical_only]
  @scientific_name = scientific_name

  parsed_data = get_redis_data
  return parsed_data if parsed_data

  cache_parsed_data(parse_scientific_name)
end