Class: Hub::JSON

Inherits:
Object
  • Object
show all
Extended by:
Forwardable, Generator
Defined in:
lib/hub/json.rb

Overview

Stupid pure Ruby JSON parser.

Defined Under Namespace

Modules: Generator

Constant Summary collapse

WSP =
/\s+/
OBJ =
/[{\[]/
HEN =
/\}/
AEN =
/\]/
COL =
/\s*:\s*/
KEY =
/\s*,\s*/
NUM =
/-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/
BOL =
/true|false/
NUL =
/null/

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Generator

generate

Constructor Details

#initialize(data) ⇒ JSON

Returns a new instance of JSON.



21
22
23
# File 'lib/hub/json.rb', line 21

def initialize data
  @scanner = StringScanner.new data.to_s
end

Instance Attribute Details

#scannerObject (readonly) Also known as: s

Returns the value of attribute scanner.



16
17
18
# File 'lib/hub/json.rb', line 16

def scanner
  @scanner
end

Class Method Details

.parse(data) ⇒ Object



6
# File 'lib/hub/json.rb', line 6

def self.parse(data) new(data).parse end

Instance Method Details

#parseObject



25
26
27
28
# File 'lib/hub/json.rb', line 25

def parse
  space
  object
end