Class: IPFS::Connection::NameCommand
- Inherits:
-
Object
- Object
- IPFS::Connection::NameCommand
- Defined in:
- lib/ipfs-api/connection.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(connection) ⇒ NameCommand
constructor
A new instance of NameCommand.
- #publish(node, key = nil) ⇒ Object
- #resolve(id = nil) ⇒ Object
Constructor Details
#initialize(connection) ⇒ NameCommand
Returns a new instance of NameCommand.
145 146 147 |
# File 'lib/ipfs-api/connection.rb', line 145 def initialize connection @connection = connection end |
Instance Method Details
#publish(node, key = nil) ⇒ Object
159 160 161 162 163 164 165 |
# File 'lib/ipfs-api/connection.rb', line 159 def publish node, key = nil params = "arg=#{CGI.escape(node.hash)}" params << "&key=#{CGI.escape(key)}" if key @connection.instance_exec(self) do JSON.parse(post("name/publish?#{params}").body)['Name'] end end |
#resolve(id = nil) ⇒ Object
149 150 151 152 153 154 155 156 157 |
# File 'lib/ipfs-api/connection.rb', line 149 def resolve id = nil @connection.instance_exec(self) do if id JSON.parse(post("name/resolve?arg=#{CGI.escape(id)}").body)['Path'] else JSON.parse(post('name/resolve').body)['Path'] end end end |