Class: IPFS::Upload::Node

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

Overview

:nodoc:

Direct Known Subclasses

FileNode, FolderNode

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, parent = nil) ⇒ Node

Returns a new instance of Node.



38
39
40
41
42
# File 'lib/ipfs-api/upload.rb', line 38

def initialize name, parent = nil
  raise "Name #{} must be a String" if not name.is_a?(String)
  @name = name
  @parent = parent
end

Instance Attribute Details

#bytesObject

Returns the value of attribute bytes.



36
37
38
# File 'lib/ipfs-api/upload.rb', line 36

def bytes
  @bytes
end

#hashObject

Returns the value of attribute hash.



36
37
38
# File 'lib/ipfs-api/upload.rb', line 36

def hash
  @hash
end

#nameObject

Returns the value of attribute name.



36
37
38
# File 'lib/ipfs-api/upload.rb', line 36

def name
  @name
end

#parentObject

Returns the value of attribute parent.



36
37
38
# File 'lib/ipfs-api/upload.rb', line 36

def parent
  @parent
end

Instance Method Details

#file?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/ipfs-api/upload.rb', line 48

def file?
  false
end

#finished?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/ipfs-api/upload.rb', line 60

def finished?
  !@hash.nil?
end

#folder?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/ipfs-api/upload.rb', line 52

def folder?
  false
end

#inspectObject



64
65
66
67
68
69
# File 'lib/ipfs-api/upload.rb', line 64

def inspect
  s = "<#{@name}"
  s << ":#{@bytes}" if defined?(@bytes)
  s << ":#{@hash}" if defined?(@hash)
  s << '>'
end

#pathObject



44
45
46
# File 'lib/ipfs-api/upload.rb', line 44

def path
  @parent.nil? ? "/#{@name}" : "#{@parent.path}/#{@name}"
end

#to_sObject



56
57
58
# File 'lib/ipfs-api/upload.rb', line 56

def to_s
  inspect
end