Class: ODDB::View::Drugs::PriceHistoryList

Inherits:
HtmlGrid::List show all
Includes:
ODDB::View::DataFormat
Defined in:
src/view/drugs/price_history.rb

Constant Summary

COMPONENTS =
{
  [0,0] => :valid_from,
  [1,0] => :exfactory,
  [2,0] => :percent_exfactory,
  [3,0] => :public,
  [4,0] => :percent_public,
  [5,0] => :authorities,
  [6,0] => :origins,
  [7,0] => :mutation_codes,
}
CSS_HEAD_MAP =
{
  [1,0] => 'subheading right',
  [3,0] => 'subheading right',
  [5,0] => 'subheading right',
}
CSS_MAP =
{
  [0,0]   => 'list',
  [1,0,5] => 'list right',
  [6,0,2] => 'list',
}
DEFAULT_HEAD_CLASS =
'subheading'
LEGACY_INTERFACE =
false
SORT_DEFAULT =
:valid_from
SORT_REVERSE =
true
SYMBOL_MAP =
{
  :valid_from => HtmlGrid::DateValue,
}

Constants inherited from HtmlGrid::List

BACKGROUND_SUFFIX

Instance Method Summary (collapse)

Methods included from ODDB::View::DataFormat

#breakline, #company_name, #most_precise_dose, #name_base, #price, #price_exfactory, #price_public

Methods included from ExternalLinks

#contact_link, #data_declaration, #external_link, #faq_link, #generic_definition, #help_link, #legal_note, #meddrugs_update, #wiki_link

Instance Method Details

- (Object) authorities(model)



41
42
43
44
45
46
47
48
# File 'src/view/drugs/price_history.rb', line 41

def authorities(model)
  collect_data(model, :authority).collect do |key|
    span = HtmlGrid::Span.new model, @session, self
    span.value = @lookandfeel.lookup(:"price_authority_#{key}") do key end
    span.set_attribute("title", @lookandfeel.lookup(:"price_authority_title_#{key}") do key end)
    span
  end
end

- (Object) collect_data(model, key)



84
85
86
87
88
# File 'src/view/drugs/price_history.rb', line 84

def collect_data(model, key)
  [:public, :exfactory].collect do |type|
    (price = model.send(type)) && price.send(key)
  end.compact.uniq
end

- (Object) exfactory(model)



49
50
51
# File 'src/view/drugs/price_history.rb', line 49

def exfactory(model)
  formatted_price(:exfactory, model) if model.exfactory
end

- (Object) mutation_codes(model)



52
53
54
55
56
# File 'src/view/drugs/price_history.rb', line 52

def mutation_codes(model)
  collect_data(model, :mutation_code).collect do |key|
    @lookandfeel.lookup(:"sl_mutation_#{key}") do key end
  end.join(', ')
end

- (Object) origins(model)



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'src/view/drugs/price_history.rb', line 57

def origins(model)
  collect_data(model, :origin).inject([]) do |memo, url_and_date|
    url, date = url_and_date.split(' ')
    link = HtmlGrid::Link.new :origin, model, @session, self
    if match = /#{ODDB.config.bsv_archives}/u.match(url)
      url = "http://bag.e-mediat.net/SL2007.WEb.external/BSV_xls_20#{match[1]}.zip"
    end
    link.href = link.value = url
    memo.push link
    if date
      memo.push ' ', date
    end
    memo
  end
end

- (Object) percent(pcnt)



72
73
74
# File 'src/view/drugs/price_history.rb', line 72

def percent(pcnt)
  "(%+3.2f %%)" % pcnt if pcnt
end

- (Object) percent_exfactory(model)



75
76
77
# File 'src/view/drugs/price_history.rb', line 75

def percent_exfactory(model)
  percent model.percent_exfactory
end

- (Object) percent_public(model)



78
79
80
# File 'src/view/drugs/price_history.rb', line 78

def percent_public(model)
  percent model.percent_public
end

- (Object) public(model)



81
82
83
# File 'src/view/drugs/price_history.rb', line 81

def public(model)
  formatted_price(:public, model) if model.public
end