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
- #pin_rm(node, recursive: true) ⇒ Object
Constructor Details
#initialize(host:, port:) ⇒ Client
Returns a new instance of Client.
18 19 20 21 |
# File 'lib/ipfs/client.rb', line 18 def initialize(host:, port:) @host = host @port = port end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
12 13 14 |
# File 'lib/ipfs/client.rb', line 12 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
12 13 14 |
# File 'lib/ipfs/client.rb', line 12 def port @port end |
Class Method Details
.default ⇒ Object
14 15 16 |
# File 'lib/ipfs/client.rb', line 14 def self.default new(host: DEFAULT_HOST, port: DEFAULT_PORT) end |
Instance Method Details
#add(file) ⇒ Object
35 36 37 |
# File 'lib/ipfs/client.rb', line 35 def add(file) Commands::Add.call self, file end |
#api_url ⇒ Object
23 24 25 |
# File 'lib/ipfs/client.rb', line 23 def api_url "#{host}:#{port}/api/#{API_VERSION}" end |
#cat(node) ⇒ Object
31 32 33 |
# File 'lib/ipfs/client.rb', line 31 def cat(node) Commands::Cat.call self, node end |