Class: Filecoin::Types::Cid
- Inherits:
-
Object
- Object
- Filecoin::Types::Cid
- Defined in:
- lib/filecoin/types/cid.rb
Instance Attribute Summary collapse
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Class Method Summary collapse
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(target) ⇒ Cid
constructor
A new instance of Cid.
- #valid? ⇒ Boolean
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
#target ⇒ Object (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_json ⇒ Object
21 22 23 24 25 |
# File 'lib/filecoin/types/cid.rb', line 21 def as_json { "/" => target, } end |
#valid? ⇒ Boolean
17 18 19 |
# File 'lib/filecoin/types/cid.rb', line 17 def valid? !target.nil? && !target.empty? end |