Class: Bitcoin::API

Inherits:
Object
  • Object
show all
Defined in:
lib/bitcoin/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ API

Returns a new instance of API.


17
18
19
20
21
22
23
# File 'lib/bitcoin/api.rb', line 17

def initialize(options = {})
  @options = {
    :host => 'localhost',
    :port => 8332,
    :ssl  => false
  }.merge(options)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.


2
3
4
# File 'lib/bitcoin/api.rb', line 2

def options
  @options
end

#paramsObject (readonly)

Returns the value of attribute params.


3
4
5
# File 'lib/bitcoin/api.rb', line 3

def params
  @params
end

Instance Method Details

#hostObject


7
# File 'lib/bitcoin/api.rb', line 7

def host; options[:host]; end

#host=(a) ⇒ Object


13
# File 'lib/bitcoin/api.rb', line 13

def host=(a); options[:host] = a; end

#passObject


6
# File 'lib/bitcoin/api.rb', line 6

def pass; options[:pass]; end

#pass=(a) ⇒ Object


12
# File 'lib/bitcoin/api.rb', line 12

def pass=(a); options[:pass] = a; end

#portObject


8
# File 'lib/bitcoin/api.rb', line 8

def port; options[:port]; end

#port=(a) ⇒ Object


14
# File 'lib/bitcoin/api.rb', line 14

def port=(a); options[:port] = a; end

#request(service_name, *params) ⇒ Object


29
30
31
32
# File 'lib/bitcoin/api.rb', line 29

def request(service_name, *params)
  req = Bitcoin::Request.new(service_name, params)
  Bitcoin::RPC.new(to_hash).dispatch(req)
end

#sslObject


9
# File 'lib/bitcoin/api.rb', line 9

def ssl;  options[:ssl];  end

#ssl=(a) ⇒ Object


15
# File 'lib/bitcoin/api.rb', line 15

def ssl=(a);  options[:ssl]  = a; end

#ssl?Boolean

Returns:

  • (Boolean)

10
# File 'lib/bitcoin/api.rb', line 10

def ssl?; options[:ssl];  end

#to_hashObject


25
26
27
# File 'lib/bitcoin/api.rb', line 25

def to_hash
  @options.dup
end

#userObject


5
# File 'lib/bitcoin/api.rb', line 5

def user; options[:user]; end

#user=(a) ⇒ Object


11
# File 'lib/bitcoin/api.rb', line 11

def user=(a); options[:user] = a; end