Class: IEX::Resources::Resource

Inherits:
Hashie::Trash
  • Object
show all
Includes:
Hashie::Extensions::IgnoreUndeclared
Defined in:
lib/iex/resources/resource.rb

Class Method Summary collapse

Class Method Details

.float_to_percentage(float_number) ⇒ Object


6
7
8
9
10
11
12
13
14
15
# File 'lib/iex/resources/resource.rb', line 6

def self.float_to_percentage(float_number)
  return unless float_number.is_a? Numeric
  return '+0.00%' if float_number.zero?

  [
    float_number > 0 ? '+' : '',
    format('%.2f', float_number * 100),
    '%'
  ].join
end

.to_dollar(amount:, ignore_cents: true) ⇒ Object


17
18
19
# File 'lib/iex/resources/resource.rb', line 17

def self.to_dollar(amount:, ignore_cents: true)
  MoneyHelper.money_to_text(amount, 'USD', nil, no_cents: ignore_cents)
end