Sha256: b7803417f6c2f75e8821c87259371eb3326a2394524cc9dcb189f170e411ed51

Contents?: true

Size: 511 Bytes

Versions: 8

Compression:

Stored size: 511 Bytes

Contents

module Coinsetter
  module Helper
    def self.parse_objects!(string, klass)
      string = "{\"empty\":[]}" if string == ""

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

    def self.parse_object!(object, klass)
      object = JSON.parse(object) if object.is_a? String

      klass.new(object)
    end

    def self.parse_message!(string)
      string = "[]" if string == ""

      JSON.parse(string)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
coinsetter-0.0.9 lib/coinsetter/helper.rb
coinsetter-0.0.8 lib/coinsetter/helper.rb
coinsetter-0.0.7 lib/coinsetter/helper.rb
coinsetter-0.0.6 lib/coinsetter/helper.rb
coinsetter-0.0.5 lib/coinsetter/helper.rb
coinsetter-0.0.4 lib/coinsetter/helper.rb
coinsetter-0.0.3 lib/coinsetter/helper.rb
coinsetter-0.0.2 lib/coinsetter/helper.rb