Class: Beowulf::Type::ExtensionJson

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/beowulf/type/extension_json.rb

Instance Method Summary collapse

Methods included from Utils

#debug, #error, #extract_signatures, #hexlify, #pakArr, #pakC, #pakHash, #pakI, #pakL!, #pakPubKey, #pakQ, #pakS, #pakStr, #pakc, #pakq, #paks, #send_log, #unhexlify, #varint, #warning

Constructor Details

#initialize(options = {}) ⇒ ExtensionJson

Returns a new instance of ExtensionJson.



8
9
10
# File 'lib/beowulf/type/extension_json.rb', line 8

def initialize(options = {})
  @data = options[:data] || ""
end

Instance Method Details

#to_bytesObject



12
13
14
# File 'lib/beowulf/type/extension_json.rb', line 12

def to_bytes
  pakStr(@data)
end

#to_json(options) ⇒ Object



20
21
22
23
24
# File 'lib/beowulf/type/extension_json.rb', line 20

def to_json(options)
  JSON.dump ({
      :data => @data
  })
end

#to_sObject



16
17
18
# File 'lib/beowulf/type/extension_json.rb', line 16

def to_s
  {"data" => @data}
end