Class: Filecoin::Types::DataRef
- Inherits:
-
Object
- Object
- Filecoin::Types::DataRef
- Defined in:
- lib/filecoin/types/data_ref.rb
Instance Attribute Summary collapse
-
#piece_cid ⇒ Object
readonly
Returns the value of attribute piece_cid.
-
#piece_size ⇒ Object
readonly
Returns the value of attribute piece_size.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#transfer_type ⇒ Object
readonly
Returns the value of attribute transfer_type.
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(transfer_type: nil, root:, piece_cid: nil, piece_size: nil) ⇒ DataRef
constructor
A new instance of DataRef.
Constructor Details
#initialize(transfer_type: nil, root:, piece_cid: nil, piece_size: nil) ⇒ DataRef
Returns a new instance of DataRef.
8 9 10 11 12 13 |
# File 'lib/filecoin/types/data_ref.rb', line 8 def initialize(transfer_type: nil, root:, piece_cid: nil, piece_size: nil) @transfer_type = transfer_type @root = Cid.new(root) @piece_cid = Cid.new(piece_cid) @piece_size = piece_size end |
Instance Attribute Details
#piece_cid ⇒ Object (readonly)
Returns the value of attribute piece_cid.
6 7 8 |
# File 'lib/filecoin/types/data_ref.rb', line 6 def piece_cid @piece_cid end |
#piece_size ⇒ Object (readonly)
Returns the value of attribute piece_size.
6 7 8 |
# File 'lib/filecoin/types/data_ref.rb', line 6 def piece_size @piece_size end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
6 7 8 |
# File 'lib/filecoin/types/data_ref.rb', line 6 def root @root end |
#transfer_type ⇒ Object (readonly)
Returns the value of attribute transfer_type.
6 7 8 |
# File 'lib/filecoin/types/data_ref.rb', line 6 def transfer_type @transfer_type end |
Instance Method Details
#as_json ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/filecoin/types/data_ref.rb', line 15 def as_json hash = { "Root" => root.as_json, } hash["TransferType"] = transfer_type unless transfer_type.nil? hash["PieceCID"] = piece_cid.as_json unless piece_cid.nil? hash["PieceSize"] = piece_size unless piece_size.nil? hash end |