class Bitcoin::Display
Public Class Methods
list(array)
click to toggle source
# File lib/bitcoin/display.rb, line 3 def self.list(array) numerize(array) end
list_by_id(array)
click to toggle source
# File lib/bitcoin/display.rb, line 11 def self.list_by_id(array) numerize(array, :id) end
list_by_symbol(array)
click to toggle source
# File lib/bitcoin/display.rb, line 7 def self.list_by_symbol(array) numerize(array, :symbol) end
list_candles(candles)
click to toggle source
# File lib/bitcoin/display.rb, line 27 def self.list_candles(candles) candles.each_with_index{ |candle, i| puts "#{(i+1).to_s.rjust(4)}. #{candle.timestamp} [#{candle.open.rjust(11)} -> #{candle.close.rjust(11)}] [#{candle.min.rjust(11)} - #{candle.max.rjust(11)}] vol: #{candle.volume.rjust(11)}" } # insert key at top and bottom of list end
list_order_book(orderbook)
click to toggle source
# File lib/bitcoin/display.rb, line 21 def self.list_order_book(orderbook) orderbook.each_with_index{ |order, i| puts "#{(i+1).to_s.rjust(4)}. #{order.timestamp.strftime("%Y-%m-%d %H:%M:%S")}: #{order.side.upcase} - Order Size: #{order.size.to_s.rjust(12)}, Price: #{order.price.to_s.rjust(12)}" } end
list_tickers(tickers)
click to toggle source
# File lib/bitcoin/display.rb, line 34 def self.list_tickers(tickers) tickers.each_with_index{ |ticker, i| puts "#{(i+1).to_s.rjust(4)}. #{ticker.symbol}" } end
list_trades(trades)
click to toggle source
# File lib/bitcoin/display.rb, line 15 def self.list_trades(trades) trades.each_with_index{ |trade, i| puts "#{(i+1).to_s.rjust(4)}. #{trade.timestamp.strftime("%Y-%m-%d %H:%M:%S")} #{trade.side.rjust(4)} #{trade.price}" } end
Private Class Methods
numerize(array, attribute = nil)
click to toggle source
input array of hashes, and attribute to be displayed
# File lib/bitcoin/display.rb, line 42 def self.numerize(array, attribute = nil) if attribute array.each_with_index{ |e, i| puts "#{i+1}. #{e.send("#{attribute}")}"} else array.each_with_index{ |e, i| puts "#{i+1}. #{e}"} end end