Class: JsonPrinter

Inherits:
Object
  • Object
show all
Defined in:
lib/neo4jr-social/json_printer.rb

Overview

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#bufObject (readonly)

Returns the value of attribute buf.



4
5
6
# File 'lib/neo4jr-social/json_printer.rb', line 4

def buf
  @buf
end

#indentObject (readonly)

Returns the value of attribute indent.



4
5
6
# File 'lib/neo4jr-social/json_printer.rb', line 4

def indent
  @indent
end

Class Method Details

.render(obj) ⇒ Object

Arguments

obj<Object>

The object to be rendered into JSON. This object and all of its associated objects must be either nil, true, false, a String, a Symbol, a Numeric, an Array, or a Hash.

Returns

<String>

The pretty-printed JSON ecoding of the given obj. This string can be parsed by any compliant JSON parser without modification.

Examples

See JsonPrinter docs.



20
21
22
# File 'lib/neo4jr-social/json_printer.rb', line 20

def self.render(obj)
  new(obj).buf
end

.render_html(obj) ⇒ Object



24
25
26
# File 'lib/neo4jr-social/json_printer.rb', line 24

def self.render_html(obj)
  render(obj).gsub(' ', '&nbsp;').gsub("\n", "<br>")
end