Class: IOTA::Models::Input

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#inspect, #symbolize_keys

Constructor Details

#initialize(options) ⇒ Input

Returns a new instance of Input.


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

def initialize(options)
  utils = IOTA::Utils::Utils.new
  options = symbolize_keys(options)

  @address = options[: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) if @address.length == 90

  @keyIndex = options[:keyIndex]
  @security = options[:security]
  @balance = options[:balance]
end

Instance Attribute Details

#addressObject

Returns the value of attribute address


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

def address
  @address
end

#balanceObject

Returns the value of attribute balance


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

def balance
  @balance
end

#keyIndexObject

Returns the value of attribute keyIndex


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

def keyIndex
  @keyIndex
end

#securityObject

Returns the value of attribute security


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

def security
  @security
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)

26
27
28
29
30
31
32
33
34
35
# File 'lib/iota/models/input.rb', line 26

def valid?
  keysToValidate = [
    { key: 'address', validator: :isAddress, args: nil },
    { key: 'security', validator: :isValue, args: nil },
    { key: 'keyIndex', validator: :isValue, args: nil }
  ]

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