module Bitso::Helper

Public Class Methods

parse_object!(object, klass) click to toggle source
# File lib/bitso/helper.rb, line 13
def self.parse_object!(object, klass)
  object = JSON.parse(object) if object.is_a? String

  klass.new(object)
end
parse_objects!(string, klass) click to toggle source
# File lib/bitso/helper.rb, line 3
def self.parse_objects!(string, klass)
  # If Bitso returned nothing (which it does if the results yield empty) 'cast' it to an array
  string = "[]" if string == ""

  objects = JSON.parse(string)
  objects.collect do |t_json|
    parse_object!(t_json, klass)
  end
end