Module: Capwatch::ConsoleFormatter

Included in:
Console
Defined in:
lib/capwatch.rb

Instance Method Summary collapse

Instance Method Details

#condition_color(value) ⇒ Object



142
143
144
145
146
147
148
149
150
151
# File 'lib/capwatch.rb', line 142

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

#fmt(n) ⇒ Object



126
127
128
# File 'lib/capwatch.rb', line 126

def fmt(n)
  '$' + n.round(2).to_s.reverse.gsub(/(\d{3})(?=\d)/, '\\1,').reverse
end

#format_btc(value) ⇒ Object



130
131
132
# File 'lib/capwatch.rb', line 130

def format_btc(value)
  format('฿%.2f', value)
end

#format_eth(value) ⇒ Object



134
135
136
# File 'lib/capwatch.rb', line 134

def format_eth(value)
  format('Ξ%.2f', value)
end

#format_percent(value) ⇒ Object



138
139
140
# File 'lib/capwatch.rb', line 138

def format_percent(value)
  format('%.2f%', value)
end