Class: Monerorequest::Decoder
- Inherits:
-
Object
- Object
- Monerorequest::Decoder
- Defined in:
- lib/monerorequest/decoder.rb
Overview
class to Decode an encoded Monerorequest
Instance Method Summary collapse
- #decode ⇒ Object
-
#initialize(request) ⇒ Decoder
constructor
A new instance of Decoder.
Constructor Details
#initialize(request) ⇒ Decoder
Returns a new instance of Decoder.
6 7 8 |
# File 'lib/monerorequest/decoder.rb', line 6 def initialize(request) @request = request end |
Instance Method Details
#decode ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/monerorequest/decoder.rb', line 10 def decode _, version, encoded_str = @request.split(":") raise RequestVersionError, "Only Request Version 1 is supported." unless version == "1" compressed_data = Base64.decode64(encoded_str) json_str = Zlib::GzipReader.new(StringIO.new(compressed_data)).read JSON.parse(json_str) end |