Class: IOTA::Models::Transaction

Inherits:
Base
  • Object
show all
Defined in:
lib/iota/models/transaction.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#inspect, #symbolize_keys

Constructor Details

#initialize(options) ⇒ Transaction

Returns a new instance of Transaction.


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/iota/models/transaction.rb', line 6

def initialize(options)
  options = symbolize_keys(options)
  @hash = options[:hash]
  @signatureMessageFragment = options[:signatureMessageFragment]
  @address = options[:address]
  @value = options[:value]
  @obsoleteTag = options[:obsoleteTag]
  @timestamp = options[:timestamp]
  @currentIndex = options[:currentIndex]
  @lastIndex = options[:lastIndex]
  @bundle = options[:bundle]
  @trunkTransaction = options[:trunkTransaction]
  @branchTransaction = options[:branchTransaction]
  @tag = options[:tag]
  @attachmentTimestamp = options[:attachmentTimestamp]
  @attachmentTimestampLowerBound = options[:attachmentTimestampLowerBound]
  @attachmentTimestampUpperBound = options[:attachmentTimestampUpperBound]
  @nonce = options[:nonce]
  @persistence = nil
end

Instance Attribute Details

#addressObject

Returns the value of attribute address


4
5
6
# File 'lib/iota/models/transaction.rb', line 4

def address
  @address
end

#attachmentTimestampObject

Returns the value of attribute attachmentTimestamp


4
5
6
# File 'lib/iota/models/transaction.rb', line 4

def attachmentTimestamp
  @attachmentTimestamp
end

#attachmentTimestampLowerBoundObject

Returns the value of attribute attachmentTimestampLowerBound


4
5
6
# File 'lib/iota/models/transaction.rb', line 4

def attachmentTimestampLowerBound
  @attachmentTimestampLowerBound
end

#attachmentTimestampUpperBoundObject

Returns the value of attribute attachmentTimestampUpperBound


4
5
6
# File 'lib/iota/models/transaction.rb', line 4

def attachmentTimestampUpperBound
  @attachmentTimestampUpperBound
end

#branchTransactionObject

Returns the value of attribute branchTransaction


4
5
6
# File 'lib/iota/models/transaction.rb', line 4

def branchTransaction
  @branchTransaction
end

#bundleObject

Returns the value of attribute bundle


4
5
6
# File 'lib/iota/models/transaction.rb', line 4

def bundle
  @bundle
end

#currentIndexObject

Returns the value of attribute currentIndex


4
5
6
# File 'lib/iota/models/transaction.rb', line 4

def currentIndex
  @currentIndex
end

#hashObject

Returns the value of attribute hash


4
5
6
# File 'lib/iota/models/transaction.rb', line 4

def hash
  @hash
end

#lastIndexObject

Returns the value of attribute lastIndex


4
5
6
# File 'lib/iota/models/transaction.rb', line 4

def lastIndex
  @lastIndex
end

#nonceObject

Returns the value of attribute nonce


4
5
6
# File 'lib/iota/models/transaction.rb', line 4

def nonce
  @nonce
end

#obsoleteTagObject

Returns the value of attribute obsoleteTag


4
5
6
# File 'lib/iota/models/transaction.rb', line 4

def obsoleteTag
  @obsoleteTag
end

#persistenceObject

Returns the value of attribute persistence


4
5
6
# File 'lib/iota/models/transaction.rb', line 4

def persistence
  @persistence
end

#signatureMessageFragmentObject

Returns the value of attribute signatureMessageFragment


4
5
6
# File 'lib/iota/models/transaction.rb', line 4

def signatureMessageFragment
  @signatureMessageFragment
end

#tagObject

Returns the value of attribute tag


4
5
6
# File 'lib/iota/models/transaction.rb', line 4

def tag
  @tag
end

#timestampObject

Returns the value of attribute timestamp


4
5
6
# File 'lib/iota/models/transaction.rb', line 4

def timestamp
  @timestamp
end

#trunkTransactionObject

Returns the value of attribute trunkTransaction


4
5
6
# File 'lib/iota/models/transaction.rb', line 4

def trunkTransaction
  @trunkTransaction
end

#valueObject

Returns the value of attribute value


4
5
6
# File 'lib/iota/models/transaction.rb', line 4

def value
  @value
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/iota/models/transaction.rb', line 27

def valid?
  keysToValidate = [
    { key: 'hash', validator: :isHash, args: nil},
    { key: 'signatureMessageFragment', validator: :isTrytes, args: 2187 },
    { key: 'address', validator: :isHash, args: nil },
    { key: 'value', validator: :isValue, args: nil },
    { key: 'obsoleteTag', validator: :isTrytes, args: 27 },
    { key: 'timestamp', validator: :isValue, args: nil },
    { key: 'currentIndex', validator: :isValue, args: nil },
    { key: 'lastIndex', validator: :isValue, args: nil },
    { key: 'bundle', validator: :isHash, args: nil },
    { key: 'trunkTransaction', validator: :isHash, args: nil },
    { key: 'branchTransaction', validator: :isHash, args: nil },
    { key: 'tag', validator: :isTrytes, args: 27 },
    { key: 'attachmentTimestamp', validator: :isValue, args: nil },
    { key: 'attachmentTimestampLowerBound', validator: :isValue, args: nil },
    { key: 'attachmentTimestampUpperBound', validator: :isValue, args: nil },
    { key: 'nonce', validator: :isTrytes, args: 27 }
  ]

  validator = IOTA::Utils::ObjectValidator.new(keysToValidate)
  validator.valid?(self)
end