Class: ODDB::Html::State::Drugs::Products

Inherits:
Global
  • Object
show all
Includes:
Util::Sort
Defined in:
lib/oddb/html/state/drugs/products.rb

Constant Summary collapse

DIRECT_EVENT =
:products
LIMIT =
true
VIEW =
View::Drugs::Products

Constants inherited from Global

Global::GLOBAL_MAP

Instance Attribute Summary

Attributes inherited from Global

#passed_turing_test

Attributes included from LoginMethods

#desired_input

Instance Method Summary collapse

Methods included from Util::Sort

#_sort, #_sort_by, #sort, #sort_by

Methods inherited from Global

transparent_login

Methods included from Events

#_compare, #_complete, #_explain_ddd_price, #_explain_price, #_fachinfo, #_feedback, #_package, #_package_by_code, #_package_infos, #_patinfo, #_remote, #_remote_comparables, #_remote_infos, #_remote_package, #_remote_packages, #_search, #_search_append_products, #_search_append_sequences, #_search_by, #_search_local, #_search_remote, #_tax_factor, #compare_remote, #ddd, #limited?, #navigation, #search

Methods inherited from Global

#_download, #compare, #explain_ddd_price, #explain_price, #fachinfo, #feedback, #home, #limit_state, #limited?, #logout, #method_missing, #navigation, #package, #package_infos, #partitioned_keys, #patinfo, #proceed_export, #proceed_poweruser, #product, #products, #remote_infos, #sequence

Methods included from PayPal::Checkout

#ajax_autofill, #checkout, #checkout_keys, #checkout_mandatory, #collect, #create_user

Methods included from LoginMethods

#login_

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ODDB::Html::State::Global

Instance Method Details

#_products(query) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/oddb/html/state/drugs/products.rb', line 21

def _products(query)
  if(@model.query == query)
    sort
  else
    super
  end
end

#initObject



17
18
19
20
# File 'lib/oddb/html/state/drugs/products.rb', line 17

def init
  sort_by(:product)
  sort
end

#intervalsObject



28
29
30
31
32
33
# File 'lib/oddb/html/state/drugs/products.rb', line 28

def intervals
  alpha, others = partitioned_keys(ODDB::Drugs::Product.name_keys(1))
  keys = alpha.collect { |key| key.upcase }
  keys.push('0-9') unless(others.empty?)
  keys
end

#sort_proc(key) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/oddb/html/state/drugs/products.rb', line 34

def sort_proc(key)
  case key
  when :atc
    Proc.new { |prod| 
      prod.atcs.compact.uniq.collect { |atc| atc.code }.sort }
  when :company
    Proc.new { |prod| 
      (multilingual = prod.send(key)) \
        && multilingual.name.send(@session.language) || '' }
  when :product
    Proc.new { |prod| prod.name.send(@session.language) || '' }
  end
end