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