Class: Ipfs::Connection::Base
- Inherits:
-
Object
- Object
- Ipfs::Connection::Base
show all
- Defined in:
- lib/ruby-ipfs-http-client/connection/base.rb
Constant Summary
collapse
- DEFAULT_BASE_PATH =
'/api/v0'
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
8
9
10
|
# File 'lib/ruby-ipfs-http-client/connection/base.rb', line 8
def host
@host
end
|
#port ⇒ Object
Returns the value of attribute port.
8
9
10
|
# File 'lib/ruby-ipfs-http-client/connection/base.rb', line 8
def port
@port
end
|
Instance Method Details
#build_uri ⇒ Object
10
11
12
|
# File 'lib/ruby-ipfs-http-client/connection/base.rb', line 10
def build_uri
URI::HTTP.build(host: @host, port: @port)
end
|
#make_persistent ⇒ Object
23
24
25
|
# File 'lib/ruby-ipfs-http-client/connection/base.rb', line 23
def make_persistent
HTTP.persistent build_uri
end
|
#up? ⇒ Boolean
14
15
16
17
18
19
20
21
|
# File 'lib/ruby-ipfs-http-client/connection/base.rb', line 14
def up?
begin
HTTP.get("http://#{@host}:#{@port}#{DEFAULT_BASE_PATH}/id")
true
rescue HTTP::ConnectionError
false
end
end
|