Class: IPFS::Upload::Node
- Inherits:
-
Object
- Object
- IPFS::Upload::Node
- Defined in:
- lib/ipfs-api/upload.rb
Overview
:nodoc:
Direct Known Subclasses
Instance Attribute Summary collapse
-
#bytes ⇒ Object
Returns the value of attribute bytes.
-
#hash ⇒ Object
Returns the value of attribute hash.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent ⇒ Object
Returns the value of attribute parent.
Instance Method Summary collapse
- #file? ⇒ Boolean
- #finished? ⇒ Boolean
- #folder? ⇒ Boolean
-
#initialize(name, parent = nil) ⇒ Node
constructor
A new instance of Node.
- #inspect ⇒ Object
- #path ⇒ Object
- #to_s ⇒ Object
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
#bytes ⇒ Object
Returns the value of attribute bytes.
36 37 38 |
# File 'lib/ipfs-api/upload.rb', line 36 def bytes @bytes end |
#hash ⇒ Object
Returns the value of attribute hash.
36 37 38 |
# File 'lib/ipfs-api/upload.rb', line 36 def hash @hash end |
#name ⇒ Object
Returns the value of attribute name.
36 37 38 |
# File 'lib/ipfs-api/upload.rb', line 36 def name @name end |
#parent ⇒ Object
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
48 49 50 |
# File 'lib/ipfs-api/upload.rb', line 48 def file? false end |
#finished? ⇒ Boolean
60 61 62 |
# File 'lib/ipfs-api/upload.rb', line 60 def finished? !@hash.nil? end |
#folder? ⇒ Boolean
52 53 54 |
# File 'lib/ipfs-api/upload.rb', line 52 def folder? false end |
#inspect ⇒ Object
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 |
#path ⇒ Object
44 45 46 |
# File 'lib/ipfs-api/upload.rb', line 44 def path @parent.nil? ? "/#{@name}" : "#{@parent.path}/#{@name}" end |
#to_s ⇒ Object
56 57 58 |
# File 'lib/ipfs-api/upload.rb', line 56 def to_s inspect end |