Class: Ipfs::HttpApi
- Inherits:
-
Object
- Object
- Ipfs::HttpApi
- Defined in:
- lib/http_api.rb
Constant Summary collapse
- DEFAULT_HOST =
'localhost'
- DEFAULT_PORT =
5001
- DEFAULT_BASE_PATH =
'/api/v0'
Instance Attribute Summary collapse
-
#base_path ⇒ Object
readonly
Returns the value of attribute base_path.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
- #call(command) ⇒ Object
-
#initialize(**api_server) ⇒ HttpApi
constructor
A new instance of HttpApi.
Constructor Details
#initialize(**api_server) ⇒ HttpApi
Returns a new instance of HttpApi.
12 13 14 15 16 |
# File 'lib/http_api.rb', line 12 def initialize(**api_server) @host = api_server[:host] || DEFAULT_HOST @port = api_server[:port] || DEFAULT_PORT @base_path = api_server[:base_path] || DEFAULT_BASE_PATH end |
Instance Attribute Details
#base_path ⇒ Object (readonly)
Returns the value of attribute base_path.
6 7 8 |
# File 'lib/http_api.rb', line 6 def base_path @base_path end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
6 7 8 |
# File 'lib/http_api.rb', line 6 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
6 7 8 |
# File 'lib/http_api.rb', line 6 def port @port end |
Instance Method Details
#call(command) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/http_api.rb', line 18 def call(command) HTTP.request( command[:verb], url(command[:path]), command[:options] ? command[:options] : {} ) end |