Class: Nem::Request::Announce

Inherits:
Object
  • Object
show all
Defined in:
lib/nem/request/announce.rb

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transaction, keypair) ⇒ Announce

Returns a new instance of Announce.



10
11
12
13
# File 'lib/nem/request/announce.rb', line 10

def initialize(transaction, keypair)
  @transaction = transaction
  @keypair = keypair
end

Instance Attribute Details

#keypairNem::Keypair

Returns the current value of keypair.

Returns:



7
8
9
# File 'lib/nem/request/announce.rb', line 7

def keypair
  @keypair
end

#transactionNem::Model::Transaction

Returns the current value of transaction.

Returns:



7
8
9
# File 'lib/nem/request/announce.rb', line 7

def transaction
  @transaction
end

Instance Method Details

#to_entity(state = nil) ⇒ Hash

Returns Attribute and value pairs.

Returns:

  • (Hash)

    Attribute and value pairs



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/nem/request/announce.rb', line 16

def to_entity(state = nil)
  entity = prepare_entity
  if Nem.debug
    Nem.logger.debug '%s' % [entity.inspect]
  end
  if state == :prepare
    { transaction: entity,
      privateKey: keypair.private }
  else
    serialized = serialize(entity)
    hex_serialized = Nem::Util::Convert.ua2hex(serialized)
    { data: Nem::Util::Convert.ua2hex(serialized),
      signature: signature(hex_serialized) }
  end
end