Class: ChromeLogger::Serializer
- Inherits:
-
Object
- Object
- ChromeLogger::Serializer
- Defined in:
- lib/chrome_logger/serializer.rb
Instance Attribute Summary collapse
-
#console ⇒ Object
readonly
Returns the value of attribute console.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(console) ⇒ Serializer
constructor
A new instance of Serializer.
- #serialize ⇒ Object
- #to_base64(utf8_encoded_json) ⇒ Object
- #to_json(data) ⇒ Object
- #to_utf8(json) ⇒ Object
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
#console ⇒ Object (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
#serialize ⇒ Object
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 |