Class: Ambito::Rate

Inherits:
Object
  • Object
show all
Defined in:
lib/ambito/rate.rb

Constant Summary collapse

{up: "📈", down: "📉", equal: "📊"}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(dollar:, buy:, sell:, value:, variation:) ⇒ Rate

Returns a new instance of Rate.



5
6
7
8
9
10
11
# File 'lib/ambito/rate.rb', line 5

def initialize(dollar:, buy:, sell:, value:, variation:)
  @dollar = dollar
  @buy = Price[buy]
  @sell = Price[sell]
  @value = Price[value]
  @variation = Variation[variation]
end

Instance Method Details

#average ⇒ Object



13
14
15
# File 'lib/ambito/rate.rb', line 13

def average
  Price[(buy + sell) / 2]
end

#to_s ⇒ Object



17
18
19
# File 'lib/ambito/rate.rb', line 17

def to_s
  "#{dollar}: #{price} #{variation.trend} #{variation}"
end