Class: Ipfs::Client

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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

#endpointObject (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

.defaultObject



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_urlObject



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

#pin_add(node, recursive: true) ⇒ Object



48
49
50
# File 'lib/ipfs-http-client-rb/client.rb', line 48

def pin_add(node, recursive: true)
  Commands::PinAdd.call self, node, recursive: recursive
end

#pin_rm(node, recursive: true) ⇒ Object



44
45
46
# File 'lib/ipfs-http-client-rb/client.rb', line 44

def pin_rm(node, recursive: true)
  Commands::PinRm.call self, node, recursive: recursive
end