Class: Capwatch::Console::Formatter
- Inherits:
-
Object
- Object
- Capwatch::Console::Formatter
- Defined in:
- lib/capwatch/console.rb
Class Method Summary collapse
- .condition_color(value) ⇒ Object
- .format_btc(value) ⇒ Object
- .format_eth(value) ⇒ Object
- .format_percent(value) ⇒ Object
- .format_usd(n) ⇒ Object
Class Method Details
.condition_color(value) ⇒ Object
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/capwatch/console.rb', line 97 def condition_color(value) percent_value = value.to_f if percent_value > 1 value.green elsif percent_value < 0 value.red else value.green end end |
.format_btc(value) ⇒ Object
85 86 87 |
# File 'lib/capwatch/console.rb', line 85 def format_btc(value) format("฿%.2f", value) end |
.format_eth(value) ⇒ Object
89 90 91 |
# File 'lib/capwatch/console.rb', line 89 def format_eth(value) format("Ξ%.2f", value) end |
.format_percent(value) ⇒ Object
93 94 95 |
# File 'lib/capwatch/console.rb', line 93 def format_percent(value) format("%.2f%", value.to_f) end |
.format_usd(n) ⇒ Object
81 82 83 |
# File 'lib/capwatch/console.rb', line 81 def format_usd(n) "$" + n.to_f.round(2).to_s.reverse.gsub(/(\d{3})(?=\d)/, '\\1,').reverse end |