Class: IPFS::Upload::FolderNode

Inherits:
Node
  • Object
show all
Defined in:
lib/ipfs-api/upload.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Attributes inherited from Node

#bytes, #hash, #name, #parent

Instance Method Summary collapse

Methods inherited from Node

#file?, #finished?, #path, #to_s

Constructor Details

#initialize(name, parent = nil, &block) ⇒ FolderNode

Returns a new instance of FolderNode.



105
106
107
108
109
# File 'lib/ipfs-api/upload.rb', line 105

def initialize name, parent = nil, &block
  super(name, parent)
  @children = []
  block.call(self) if block_given?
end

Instance Attribute Details

#childrenObject

Returns the value of attribute children.



103
104
105
# File 'lib/ipfs-api/upload.rb', line 103

def children
  @children
end

Instance Method Details

#add_file(file, content = nil, &block) ⇒ Object



120
121
122
# File 'lib/ipfs-api/upload.rb', line 120

def add_file file, content = nil, &block
  (@children << FileNode.new(file, self, content, &block)).last
end

#add_folder(folder, &block) ⇒ Object



124
125
126
# File 'lib/ipfs-api/upload.rb', line 124

def add_folder folder, &block
  (@children << FolderNode.new(folder, self, &block)).last
end

#add_node(node) ⇒ Object



115
116
117
118
# File 'lib/ipfs-api/upload.rb', line 115

def add_node node
  node.parent = self
  (@children << node).last
end

#folder?Boolean

Returns:

  • (Boolean)


111
112
113
# File 'lib/ipfs-api/upload.rb', line 111

def folder?
  true
end

#inspectObject



128
129
130
# File 'lib/ipfs-api/upload.rb', line 128

def inspect
  "folder:#{super}#{children}"
end