Class: Radiator::Type::Price

Inherits:
Serializer show all
Defined in:
lib/radiator/type/price.rb

Instance Method Summary collapse

Methods included from Utils

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

Constructor Details

#initialize(value) ⇒ Price

Returns a new instance of Price.



5
6
7
8
9
10
# File 'lib/radiator/type/price.rb', line 5

def initialize(value)
  super(:price, value)
  
  @base = Hive::Type::Amount.new(@value[:base])
  @quote = Hive::Type::Amount.new(@value[:quote])
end

Instance Method Details

#to_bytesObject



12
13
14
# File 'lib/radiator/type/price.rb', line 12

def to_bytes
  @base.to_bytes + @quote.to_bytes
end

#to_hObject



16
17
18
# File 'lib/radiator/type/price.rb', line 16

def to_h
  {@key => {base: @base, quote: @quote}}
end

#to_sObject



20
21
22
# File 'lib/radiator/type/price.rb', line 20

def to_s
  to_h.to_json
end