class Fcoin::RealTime::DepthFormatter
Attributes
data[RW]
Public Class Methods
new(data)
click to toggle source
# File lib/fcoin/realtime/formatter/depth_formatter.rb, line 11 def initialize(data) self.data = data end
Public Instance Methods
formatted_data()
click to toggle source
Format response data for JSON
@return [Hash]
# File lib/fcoin/realtime/formatter/depth_formatter.rb, line 18 def formatted_data self.data['bids'] = adjusted('bids') self.data['asks'] = adjusted('asks') data end
Private Instance Methods
adjusted(type)
click to toggle source
# File lib/fcoin/realtime/formatter/depth_formatter.rb, line 26 def adjusted(type) orders = data[type].dup orders.in_groups_of(2).map do |order| { "price" => order[0], "amount" => order[1] } end end