Class: MongoHTTPSync::Parser::Handler
- Inherits:
-
Oj::ScHandler
- Object
- Oj::ScHandler
- MongoHTTPSync::Parser::Handler
- Defined in:
- lib/mongo_http_sync/parser.rb
Instance Attribute Summary collapse
-
#ndocs ⇒ Object
readonly
Returns the value of attribute ndocs.
Instance Method Summary collapse
- #array_append(a, v) ⇒ Object
- #array_start ⇒ Object
- #error(message, line, column) ⇒ Object
- #hash_end ⇒ Object
- #hash_set(h, k, v) ⇒ Object
- #hash_start ⇒ Object
-
#initialize(block) ⇒ Handler
constructor
A new instance of Handler.
Constructor Details
#initialize(block) ⇒ Handler
Returns a new instance of Handler.
12 13 14 15 16 |
# File 'lib/mongo_http_sync/parser.rb', line 12 def initialize(block) @block = block @level = 0 @ndocs = 0 end |
Instance Attribute Details
#ndocs ⇒ Object (readonly)
Returns the value of attribute ndocs.
11 12 13 |
# File 'lib/mongo_http_sync/parser.rb', line 11 def ndocs @ndocs end |
Instance Method Details
#array_append(a, v) ⇒ Object
41 42 43 |
# File 'lib/mongo_http_sync/parser.rb', line 41 def array_append(a,v) a << v end |
#array_start ⇒ Object
37 38 39 |
# File 'lib/mongo_http_sync/parser.rb', line 37 def array_start [] end |
#error(message, line, column) ⇒ Object
45 46 47 |
# File 'lib/mongo_http_sync/parser.rb', line 45 def error(, line, column) throw "#{} (line: #{line}, column: #{column})" end |
#hash_end ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/mongo_http_sync/parser.rb', line 25 def hash_end @level -= 1 if @level.zero? @block.call @root_hash if @level.zero? @ndocs += 1 end end |
#hash_set(h, k, v) ⇒ Object
33 34 35 |
# File 'lib/mongo_http_sync/parser.rb', line 33 def hash_set(h,k,v) h[k.to_sym] = v end |
#hash_start ⇒ Object
18 19 20 21 22 23 |
# File 'lib/mongo_http_sync/parser.rb', line 18 def hash_start @hash = {} @root_hash = @hash if @level.zero? @level += 1 @hash end |