Class: Gera::DirectionRateDecorator

Inherits:
ApplicationDecorator
  • Object
show all
Includes:
Mathematic
Defined in:
app/decorators/gera/direction_rate_decorator.rb

Instance Method Summary collapse

Methods included from Mathematic

#calculate_base_rate, #calculate_comission, #calculate_finite_rate, #calculate_profits, #calculate_total_using_regular_comission, #calculate_total_using_reverse_comission, #diff_percents, #money_exchange, #money_reverse_exchange

Instance Method Details

#base_rate_valueObject



35
36
37
# File 'app/decorators/gera/direction_rate_decorator.rb', line 35

def base_rate_value
  h.currency_rate_mode_detailed object.currency_rate
end

#created_atObject



29
30
31
32
33
# File 'app/decorators/gera/direction_rate_decorator.rb', line 29

def created_at
  h.link_to h.direction_rate_path(object) do
    I18n.l object.created_at, format: :long
  end
end

#directionObject



17
18
19
# File 'app/decorators/gera/direction_rate_decorator.rb', line 17

def direction
  "#{h.ps_icon object.ps_from}(#{object.ps_from.currency}) → #{h.ps_icon object.ps_to}(#{object.ps_to.currency})".html_safe
end

#inverse_directionObject



8
9
10
11
12
13
14
15
# File 'app/decorators/gera/direction_rate_decorator.rb', line 8

def inverse_direction
  h.link_to h.direction_rate_path(object.inverse_direction_rate), class: 'text-muted' do
    dd = DirectionRateDecorator.new(object.inverse_direction_rate)
    buffer = dd.direction
    buffer << ' '
    buffer << dd.rate_value
  end
end

#ps_comissionObject



25
26
27
# File 'app/decorators/gera/direction_rate_decorator.rb', line 25

def ps_comission
  object.ps_comission.to_percent
end

#rate_percentObject



39
40
41
# File 'app/decorators/gera/direction_rate_decorator.rb', line 39

def rate_percent
  object.rate_percent.to_percent
end

#rate_valueObject



43
44
45
# File 'app/decorators/gera/direction_rate_decorator.rb', line 43

def rate_value
  h.rate_humanized_description(object.rate_value, object.ps_from.currency, object.ps_to.currency)
end

#titleObject



21
22
23
# File 'app/decorators/gera/direction_rate_decorator.rb', line 21

def title
  [object.ps_from, object.ps_to].join('->')
end