Module: Gera::DirectionRateHelper

Defined in:
app/helpers/gera/direction_rate_helper.rb

Instance Method Summary collapse

Instance Method Details

#direction_rate_cell_data_attr(direction) ⇒ Object



9
10
11
# File 'app/helpers/gera/direction_rate_helper.rb', line 9

def direction_rate_cell_data_attr(direction)
  rate_cell_data_attr(direction).merge href: direction_rate_path(direction.direction_rate.try(:id) || 0)
end

#exchange_rate_cell_data_attr(direction) ⇒ Object



5
6
7
# File 'app/helpers/gera/direction_rate_helper.rb', line 5

def exchange_rate_cell_data_attr(direction)
  rate_cell_data_attr(direction).merge href: operator_exchange_rate_path(direction.exchange_rate)
end

#rate_cell_data_attr(direction) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/helpers/gera/direction_rate_helper.rb', line 13

def rate_cell_data_attr(direction)
  return {} unless show_direction_popover?

  {
    toggle: 'ajax-popover',
    container: :body,
    popover_content_url: details_exchange_rate_path(direction.exchange_rate),
    trigger: :hover,
    html: 'true',
    placement: :bottom,
    animation: false,
    delay: 0
  }
end

#rate_humanized_description(rate_value, cur_from, cur_to) ⇒ Object



28
29
30
31
32
33
34
# File 'app/helpers/gera/direction_rate_helper.rb', line 28

def rate_humanized_description(rate_value, cur_from, cur_to)
  if rate_value < 1
    t '.sell_for', cur_to: cur_to, value: (1.0 / rate_value).round(3), cur_from: cur_from
  else
    t '.buy_for', cur_to: cur_to, value: rate_value.round(3), cur_from: cur_from
  end
end