Class: Bitcoin::API
- Inherits:
-
Object
- Object
- Bitcoin::API
- Defined in:
- lib/bitcoin/api.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
- #host ⇒ Object
- #host=(a) ⇒ Object
-
#initialize(options = {}) ⇒ API
constructor
A new instance of API.
- #pass ⇒ Object
- #pass=(a) ⇒ Object
- #port ⇒ Object
- #port=(a) ⇒ Object
- #request(service_name, *params) ⇒ Object
- #ssl ⇒ Object
- #ssl=(a) ⇒ Object
- #ssl? ⇒ Boolean
- #to_hash ⇒ Object
- #user ⇒ Object
- #user=(a) ⇒ Object
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 = { :host => 'localhost', :port => 8332, :ssl => false }.merge() end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
2 3 4 |
# File 'lib/bitcoin/api.rb', line 2 def @options end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
3 4 5 |
# File 'lib/bitcoin/api.rb', line 3 def params @params end |
Instance Method Details
#host ⇒ Object
7 |
# File 'lib/bitcoin/api.rb', line 7 def host; [:host]; end |
#host=(a) ⇒ Object
13 |
# File 'lib/bitcoin/api.rb', line 13 def host=(a); [:host] = a; end |
#pass ⇒ Object
6 |
# File 'lib/bitcoin/api.rb', line 6 def pass; [:pass]; end |
#pass=(a) ⇒ Object
12 |
# File 'lib/bitcoin/api.rb', line 12 def pass=(a); [:pass] = a; end |
#port ⇒ Object
8 |
# File 'lib/bitcoin/api.rb', line 8 def port; [:port]; end |
#port=(a) ⇒ Object
14 |
# File 'lib/bitcoin/api.rb', line 14 def port=(a); [: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 |
#ssl ⇒ Object
9 |
# File 'lib/bitcoin/api.rb', line 9 def ssl; [:ssl]; end |
#ssl=(a) ⇒ Object
15 |
# File 'lib/bitcoin/api.rb', line 15 def ssl=(a); [:ssl] = a; end |
#ssl? ⇒ Boolean
10 |
# File 'lib/bitcoin/api.rb', line 10 def ssl?; [:ssl]; end |
#to_hash ⇒ Object
25 26 27 |
# File 'lib/bitcoin/api.rb', line 25 def to_hash @options.dup end |
#user ⇒ Object
5 |
# File 'lib/bitcoin/api.rb', line 5 def user; [:user]; end |
#user=(a) ⇒ Object
11 |
# File 'lib/bitcoin/api.rb', line 11 def user=(a); [:user] = a; end |