Class: ODDB::ReadonlyServer

Inherits:
Object show all
Defined in:
ext/readonly/src/readonly_server.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) get_currency_rate(symbol)



7
8
9
# File 'ext/readonly/src/readonly_server.rb', line 7

def get_currency_rate(symbol)
  ODDB::Currency.rate('CHF', symbol)
end

- (Object) remote_comparables(package)



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'ext/readonly/src/readonly_server.rb', line 10

def remote_comparables(package)
  package = ODDB::Remote::Package.new(package)
  sequence = package.sequence
  comparables = []
  atcs = ODBA.cache.retrieve_from_index('atc_index', sequence.atc_code)
  if(atcs.size == 1 && atc = atcs.first)
    atc.sequences.each { |seq|
      if(sequence.comparable?(seq))
        comparables.concat seq.packages.values.select { |pac|
          package.comparable?(pac)
        }
      end
    }
  end
  ODBA::DRbWrapper.new comparables
end

- (Object) remote_each_atc_class(&block)



26
27
28
29
30
# File 'ext/readonly/src/readonly_server.rb', line 26

def remote_each_atc_class(&block)
  ODDB::AtcClass.odba_extent do |atc|
    block.call ODBA::DRbWrapper.new(atc)
  end
end

- (Object) remote_each_company(&block)

for migration to ch.oddb.org



31
32
33
34
35
36
# File 'ext/readonly/src/readonly_server.rb', line 31

def remote_each_company(&block) # for migration to ch.oddb.org
  ODDB::Company.odba_extent.each do |comp|
    block.call ODBA::DRbWrapper.new(comp)
  end
  nil # don't try to pass all registrations across DRb-Land
end

- (Object) remote_each_package(&block)



37
38
39
40
41
42
43
44
# File 'ext/readonly/src/readonly_server.rb', line 37

def remote_each_package(&block)
  ODDB::Package.odba_extent.each do |pac|
    if(pac.public? && !pac.narcotic?)
      block.call ODBA::DRbWrapper.new(pac)
    end
  end
  nil # don't try to pass all registrations across DRb-Land
end

- (Object) remote_export(name)



45
46
47
48
49
# File 'ext/readonly/src/readonly_server.rb', line 45

def remote_export(name)
  ODDB::Exporter.new(self).export_helper(name) { |path|
    yield path
  }
end

- (Object) remote_packages(query)



50
51
52
53
54
55
56
57
58
59
# File 'ext/readonly/src/readonly_server.rb', line 50

def remote_packages(query)
  seqs = ODBA.cache.retrieve_from_index('sequence_index_exact', query)
  if(seqs.empty?)
    seqs = ODBA.cache.\
      retrieve_from_index('substance_index_sequence', query)
  end
  ODBA::DRbWrapper.new seqs.collect { |seq|
    seq.public_packages
  }.flatten
end