Class: ODDB::Html::State::Drugs::Result
- Includes:
- Util::PackageSort
- Defined in:
- lib/oddb/html/state/drugs/result.rb
Defined Under Namespace
Classes: Paginator
Constant Summary collapse
Constants inherited from Global
Instance Attribute Summary
Attributes inherited from Global
Attributes included from LoginMethods
Instance Method Summary collapse
- #_search(query, dstype) ⇒ Object
- #_sort_by(model, reverse, &sorter) ⇒ Object
- #direct_event ⇒ Object
- #init ⇒ Object
- #paginate ⇒ Object
- #partition! ⇒ Object
Methods included from Util::PackageSort
Methods included from Util::Sort
#_sort, #sort, #sort_by, #sort_proc
Methods inherited from Global
Methods included from Events
#_compare, #_complete, #_explain_ddd_price, #_explain_price, #_fachinfo, #_feedback, #_package, #_package_by_code, #_package_infos, #_patinfo, #_products, #_remote, #_remote_comparables, #_remote_infos, #_remote_package, #_remote_packages, #_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
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ODDB::Html::State::Global
Instance Method Details
#_search(query, dstype) ⇒ Object
108 109 110 111 112 113 114 115 |
# File 'lib/oddb/html/state/drugs/result.rb', line 108 def _search(query, dstype) if(@model.query == query && @model.dstype == dstype) paginate sort else super end end |
#_sort_by(model, reverse, &sorter) ⇒ Object
116 117 118 119 120 |
# File 'lib/oddb/html/state/drugs/result.rb', line 116 def _sort_by(model, reverse, &sorter) model.collect! { |array| super(array, reverse, &sorter) } end |
#direct_event ⇒ Object
74 75 76 |
# File 'lib/oddb/html/state/drugs/result.rb', line 74 def direct_event [:search, :query, @model.query, :dstype, @model.dstype] end |
#init ⇒ Object
65 66 67 68 69 70 71 72 73 |
# File 'lib/oddb/html/state/drugs/result.rb', line 65 def init partition! sort_by(:price_public, 0) sort_by(:size, 0) sort_by(:active_agents, []) sort_by(:product, nil) paginate sort end |
#paginate ⇒ Object
77 78 79 80 81 82 83 84 85 |
# File 'lib/oddb/html/state/drugs/result.rb', line 77 def paginate if(@session.user_input(:page)) @session.(:display, 'paged') end @model.display = @session.(:display) if(page = @session.user_input(:page)) @model.page = page end end |
#partition! ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/oddb/html/state/drugs/result.rb', line 86 def partition! atcs = {} @model = Paginator.new(@model) @model.total = @model.size while(package = @model.shift) code = (atc = package.atc) ? atc.code : 'X' (atcs[code] ||= ODDB::Util::AnnotatedList.new(:atc => atc)).push(package) end count = 0 limit = @session.pagelength atcs.sort.each { |code, array| count += array.size ## count > array.size: very large atc-classes may instantly get the count # to be > limit if(count > array.size && count > limit) @model.next_page! count = array.size end @model.push(array) } @model.page = 0 end |