Class: Nis::Transaction::Transfer

Inherits:
Object
  • Object
show all
Includes:
Mixin::Struct
Defined in:
lib/nis/transaction/transfer.rb

Overview

Constant Summary collapse

TYPE =

257 (transfer transaction)

0x0101

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mixin::Struct

#[], #to_hash, #to_json

Constructor Details

#initialize(recipient, amount, message = '', mosaics: [], network: :testnet) ⇒ Transfer

Returns a new instance of Transfer.



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/nis/transaction/transfer.rb', line 30

def initialize(recipient, amount, message = '', mosaics: [], network: :testnet)
  @type = TYPE
  @network = network

  @recipient = recipient
  @amount = amount
  @message = message.is_a?(Nis::Struct::Message) ?
    message :
    Nis::Struct::Message.new(message.to_s)
  @fee = Nis::Fee::Transfer.new(self)
  @mosaics = mosaics
end

Instance Attribute Details

#amountInteger

Returns the current value of amount.

Returns:

  • (Integer)

    the current value of amount



17
18
19
# File 'lib/nis/transaction/transfer.rb', line 17

def amount
  @amount
end

#deadlineInteger

Returns the current value of deadline.

Returns:

  • (Integer)

    the current value of deadline



17
18
19
# File 'lib/nis/transaction/transfer.rb', line 17

def deadline
  @deadline
end

#feeNis::Fee::Transfer

Returns the current value of fee.

Returns:



17
18
19
# File 'lib/nis/transaction/transfer.rb', line 17

def fee
  @fee
end

#messageNis::Struct::Message

Returns the current value of message.

Returns:



17
18
19
# File 'lib/nis/transaction/transfer.rb', line 17

def message
  @message
end

#mosaicsArray <Nis::Struct::MosaicId>

Returns the current value of mosaics.

Returns:



17
18
19
# File 'lib/nis/transaction/transfer.rb', line 17

def mosaics
  @mosaics
end

#networkSymbol

Returns the current value of network.

Returns:

  • (Symbol)

    the current value of network



17
18
19
# File 'lib/nis/transaction/transfer.rb', line 17

def network
  @network
end

#recipientString

Returns the current value of recipient.

Returns:

  • (String)

    the current value of recipient



17
18
19
# File 'lib/nis/transaction/transfer.rb', line 17

def recipient
  @recipient
end

#signerString

Returns the current value of signer.

Returns:

  • (String)

    the current value of signer



17
18
19
# File 'lib/nis/transaction/transfer.rb', line 17

def signer
  @signer
end

#timeStampObject Also known as: timestamp

Returns the value of attribute timeStamp.



21
22
23
# File 'lib/nis/transaction/transfer.rb', line 21

def timeStamp
  @timeStamp
end

#timestamp=(value) ⇒ Integer

Returns the newly set value.

Parameters:

  • value (Integer)

    the value to set the attribute timestamp to.

Returns:

  • (Integer)

    the newly set value



17
18
19
# File 'lib/nis/transaction/transfer.rb', line 17

def timestamp=(value)
  @timestamp = value
end

#typeInteger

Returns the current value of type.

Returns:

  • (Integer)

    the current value of type



17
18
19
# File 'lib/nis/transaction/transfer.rb', line 17

def type
  @type
end

#versionInteger

Returns the current value of version.

Returns:

  • (Integer)

    the current value of version



17
18
19
# File 'lib/nis/transaction/transfer.rb', line 17

def version
  @version
end

Instance Method Details

#has_message?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/nis/transaction/transfer.rb', line 43

def has_message?
  @message.bytesize > 0
end

#has_mosaics?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/nis/transaction/transfer.rb', line 47

def has_mosaics?
  @mosaics.size > 0
end