Sha256: 938b18267f391f27afed111c6d4274c29afeb5fa17da2ff58e0065af3ae760d1
Contents?: true
Size: 795 Bytes
Versions: 4
Compression:
Stored size: 795 Bytes
Contents
require 'json' class Bitcoin::Request attr_reader :service_name, :params def initialize(service_name, params = []) @service_name = service_name @params = params.dup # bitcoin rejects null values even for optional params. Since # even params following those may have default non-nil values, # we'll assume the first non-nil value marks a set of optional # params, and drop it and everything following it. # # ex: # [nil] => [] # [1,nil,nil] => [1] # [1,nil,nil,1] => [1] if index = @params.index(nil) @params = @params[0...index] end end def to_hash { :method => service_name, :params => params, :id => "jsonrpc" } end def to_post_data to_hash.to_json end end
Version data entries
4 entries across 4 versions & 2 rubygems
Version | Path |
---|---|
bitcoin-client-0.0.3 | lib/bitcoin/request.rb |
bitcoin-client-0.0.2 | lib/bitcoin/request.rb |
ramontayag-bitcoin-client-0.1.0 | lib/bitcoin/request.rb |
bitcoin-client-0.0.1 | lib/bitcoin/request.rb |