Class: Filecoin::Types::Cid

Inherits:
Object
  • Object
show all
Defined in:
lib/filecoin/types/cid.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target) ⇒ Cid

Returns a new instance of Cid.



13
14
15
# File 'lib/filecoin/types/cid.rb', line 13

def initialize(target)
  @target = target
end

Instance Attribute Details

#targetObject (readonly)

Returns the value of attribute target.



4
5
6
# File 'lib/filecoin/types/cid.rb', line 4

def target
  @target
end

Class Method Details

.new(target) ⇒ Object



6
7
8
9
10
11
# File 'lib/filecoin/types/cid.rb', line 6

def self.new(target)
  return nil if target.nil?
  return target if target.is_a?(Cid)

  super
end

Instance Method Details

#as_jsonObject



21
22
23
24
25
# File 'lib/filecoin/types/cid.rb', line 21

def as_json
  {
    "/" => target,
  }
end

#valid?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/filecoin/types/cid.rb', line 17

def valid?
  !target.nil? && !target.empty?
end