Class: Ipfs::Client
- Inherits:
-
Object
- Object
- Ipfs::Client
- Defined in:
- lib/ipfs-http-client-rb/client.rb
Constant Summary collapse
- DEFAULT_ENDPOINT =
'http://localhost:5000'.freeze
- API_VERSION =
'v0'.freeze
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
Class Method Summary collapse
Instance Method Summary collapse
- #add(file) ⇒ Object
- #add_dir(dir) ⇒ Object
- #base_url ⇒ Object
- #cat(node) ⇒ Object
- #cat_to_file(node, path) ⇒ Object
-
#initialize(endpoint) ⇒ Client
constructor
A new instance of Client.
- #ls(node) ⇒ Object
- #pin_add(node, recursive: true) ⇒ Object
- #pin_rm(node, recursive: true) ⇒ Object
Constructor Details
#initialize(endpoint) ⇒ Client
Returns a new instance of Client.
16 17 18 |
# File 'lib/ipfs-http-client-rb/client.rb', line 16 def initialize(endpoint) @endpoint = endpoint end |
Instance Attribute Details
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
10 11 12 |
# File 'lib/ipfs-http-client-rb/client.rb', line 10 def endpoint @endpoint end |
Class Method Details
.default ⇒ Object
12 13 14 |
# File 'lib/ipfs-http-client-rb/client.rb', line 12 def self.default new(DEFAULT_ENDPOINT) end |
Instance Method Details
#add(file) ⇒ Object
36 37 38 |
# File 'lib/ipfs-http-client-rb/client.rb', line 36 def add(file) Commands::Add.call self, file end |
#add_dir(dir) ⇒ Object
40 41 42 |
# File 'lib/ipfs-http-client-rb/client.rb', line 40 def add_dir(dir) Commands::AddDir.call self, dir end |
#base_url ⇒ Object
20 21 22 |
# File 'lib/ipfs-http-client-rb/client.rb', line 20 def base_url "#{endpoint}/api/#{API_VERSION}" end |
#cat(node) ⇒ Object
28 29 30 |
# File 'lib/ipfs-http-client-rb/client.rb', line 28 def cat(node) Commands::Cat.call self, node end |
#cat_to_file(node, path) ⇒ Object
32 33 34 |
# File 'lib/ipfs-http-client-rb/client.rb', line 32 def cat_to_file(node, path) Commands::CatToFile.call self, node, path end |
#ls(node) ⇒ Object
24 25 26 |
# File 'lib/ipfs-http-client-rb/client.rb', line 24 def ls(node) Commands::Ls.call self, node end |