Class: IPFS::Client
- Inherits:
-
Object
- Object
- IPFS::Client
- Defined in:
- lib/ipfs/client.rb
Constant Summary collapse
- DEFAULT_HOST =
'http://localhost'.freeze
- DEFAULT_PORT =
5001- API_VERSION =
'v0'.freeze
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Class Method Summary collapse
Instance Method Summary collapse
- #add(file) ⇒ Object
- #api_url ⇒ Object
- #cat(node) ⇒ Object
-
#initialize(host:, port:) ⇒ Client
constructor
A new instance of Client.
- #ls(node) ⇒ Object
Constructor Details
#initialize(host:, port:) ⇒ Client
Returns a new instance of Client.
17 18 19 20 |
# File 'lib/ipfs/client.rb', line 17 def initialize(host:, port:) @host = host @port = port end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
11 12 13 |
# File 'lib/ipfs/client.rb', line 11 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
11 12 13 |
# File 'lib/ipfs/client.rb', line 11 def port @port end |
Class Method Details
.default ⇒ Object
13 14 15 |
# File 'lib/ipfs/client.rb', line 13 def self.default new(host: DEFAULT_HOST, port: DEFAULT_PORT) end |
Instance Method Details
#add(file) ⇒ Object
34 35 36 |
# File 'lib/ipfs/client.rb', line 34 def add(file) Commands::Add.call self, file end |
#api_url ⇒ Object
22 23 24 |
# File 'lib/ipfs/client.rb', line 22 def api_url "#{host}:#{port}/api/#{API_VERSION}" end |