Class: Ambito::Rate
- Inherits:
-
Object
- Object
- Ambito::Rate
- Defined in:
- lib/ambito/rate.rb
Constant Summary collapse
- TRENDS =
{up: "📈", down: "📉", equal: "📊"}.freeze
Instance Method Summary collapse
- #average ⇒ Object
-
#initialize(dollar:, buy:, sell:, value:, variation:) ⇒ Rate
constructor
A new instance of Rate.
- #to_s ⇒ Object
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 |