Class: IOTA::Models::Transfer
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#hmacKey ⇒ Object
Returns the value of attribute hmacKey.
-
#message ⇒ Object
Returns the value of attribute message.
-
#obsoleteTag ⇒ Object
Returns the value of attribute obsoleteTag.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(options) ⇒ Transfer
constructor
A new instance of Transfer.
- #valid? ⇒ Boolean
Constructor Details
#initialize(options) ⇒ Transfer
Returns a new instance of Transfer.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/iota/models/transfer.rb', line 6 def initialize() @utils = IOTA::Utils::Utils.new = symbolize_keys() @address = [:address] || nil if @address.nil? raise StandardError, "address not provided for transfer" end if @address.length == 90 && !@utils.isValidChecksum(@address) raise StandardError, "Invalid checksum: #{thisTransfer[:address]}" end @address = @utils.noChecksum(@address) @message = [:message] || '' @obsoleteTag = [:tag] || [:obsoleteTag] || '' @value = [:value] @hmacKey = [:hmacKey] || nil if @hmacKey @message = ('9'*244) + @message end end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
4 5 6 |
# File 'lib/iota/models/transfer.rb', line 4 def address @address end |
#hmacKey ⇒ Object
Returns the value of attribute hmacKey.
4 5 6 |
# File 'lib/iota/models/transfer.rb', line 4 def hmacKey @hmacKey end |
#message ⇒ Object
Returns the value of attribute message.
4 5 6 |
# File 'lib/iota/models/transfer.rb', line 4 def @message end |
#obsoleteTag ⇒ Object
Returns the value of attribute obsoleteTag.
4 5 6 |
# File 'lib/iota/models/transfer.rb', line 4 def obsoleteTag @obsoleteTag end |
#value ⇒ Object
Returns the value of attribute value.
4 5 6 |
# File 'lib/iota/models/transfer.rb', line 4 def value @value end |
Instance Method Details
#valid? ⇒ Boolean
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/iota/models/transfer.rb', line 31 def valid? keysToValidate = [ { key: 'address', validator: :isAddress, args: nil }, { key: 'value', validator: :isValue, args: nil }, { key: 'message', validator: :isTrytes, args: nil }, { key: 'obsoleteTag', validator: :isTrytes, args: '0,27' } ] validator = IOTA::Utils::ObjectValidator.new(keysToValidate) validator.valid?(self) end |