class Fcoin::Formatter
Attributes
body[RW]
Public Class Methods
new(body)
click to toggle source
# File lib/fcoin/formatter.rb, line 6 def initialize(body) self.body = body end
Public Instance Methods
formatted_body()
click to toggle source
Format body
# File lib/fcoin/formatter.rb, line 11 def formatted_body formatter.present? ? formatter.formatted_body : body end
Private Instance Methods
formatter()
click to toggle source
# File lib/fcoin/formatter.rb, line 19 def formatter if use_formatter?(body) case body['data']['type'] when /ticker/ TickerFormatter.new(body) when /depth/ DepthFormatter.new(body) else nil end else nil end end
use_formatter?(body)
click to toggle source
# File lib/fcoin/formatter.rb, line 34 def use_formatter?(body) !(body['data'].nil? || !body['data'].is_a?(Hash) || body['data']['type'].nil?) end