Class: ChromeLogger::Serializer

Inherits:
Object
  • Object
show all
Defined in:
lib/chrome_logger/serializer.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(console) ⇒ Serializer

Returns a new instance of Serializer.



13
14
15
# File 'lib/chrome_logger/serializer.rb', line 13

def initialize( console )
  @console = console
end

Instance Attribute Details

#consoleObject (readonly)

Returns the value of attribute console.



6
7
8
# File 'lib/chrome_logger/serializer.rb', line 6

def console
  @console
end

Class Method Details

.serialize(console) ⇒ Object



8
9
10
11
# File 'lib/chrome_logger/serializer.rb', line 8

def self.serialize( console )
  serializer = new console
  serializer.serialize
end

Instance Method Details

#serializeObject



17
18
19
# File 'lib/chrome_logger/serializer.rb', line 17

def serialize
  to_base64 to_utf8( to_json console.data )
end

#to_base64(utf8_encoded_json) ⇒ Object



21
22
23
# File 'lib/chrome_logger/serializer.rb', line 21

def to_base64( utf8_encoded_json )
  Base64.encode64(utf8_encoded_json).gsub("\n", "")
end

#to_json(data) ⇒ Object



25
26
27
# File 'lib/chrome_logger/serializer.rb', line 25

def to_json( data )
  MultiJson.dump data
end

#to_utf8(json) ⇒ Object



29
30
31
# File 'lib/chrome_logger/serializer.rb', line 29

def to_utf8( json )
  json.encode 'UTF-8'
end