Class: BEL::JSON::StreamHandler
- Inherits:
-
Oj::ScHandler
- Object
- Oj::ScHandler
- BEL::JSON::StreamHandler
- Defined in:
- lib/bel/json/adapter/oj.rb
Instance Method Summary collapse
- #array_append(array, value) ⇒ Object
- #array_end ⇒ Object
- #array_start ⇒ Object
- #error(message, line, column) ⇒ Object
- #hash_end ⇒ Object
- #hash_set(hash, key, value) ⇒ Object
- #hash_start ⇒ Object
-
#initialize(callable) ⇒ StreamHandler
constructor
A new instance of StreamHandler.
Constructor Details
#initialize(callable) ⇒ StreamHandler
Returns a new instance of StreamHandler.
69 70 71 |
# File 'lib/bel/json/adapter/oj.rb', line 69 def initialize(callable) @callable = callable end |
Instance Method Details
#array_append(array, value) ⇒ Object
91 92 93 94 |
# File 'lib/bel/json/adapter/oj.rb', line 91 def array_append(array, value) array << value @array = array end |
#array_end ⇒ Object
96 97 98 |
# File 'lib/bel/json/adapter/oj.rb', line 96 def array_end() @callable.call @array end |
#array_start ⇒ Object
86 87 88 89 |
# File 'lib/bel/json/adapter/oj.rb', line 86 def array_start @array = [] @array end |
#error(message, line, column) ⇒ Object
100 101 102 103 |
# File 'lib/bel/json/adapter/oj.rb', line 100 def error(, line, column) msg = "Parse error at line #{line}, column #{column}: #{}" raise Oj::ParseError.new(msg) end |
#hash_end ⇒ Object
77 78 79 |
# File 'lib/bel/json/adapter/oj.rb', line 77 def hash_end @callable.call @hash end |
#hash_set(hash, key, value) ⇒ Object
81 82 83 84 |
# File 'lib/bel/json/adapter/oj.rb', line 81 def hash_set(hash, key, value) hash[key] = value @hash = hash end |
#hash_start ⇒ Object
73 74 75 |
# File 'lib/bel/json/adapter/oj.rb', line 73 def hash_start {} end |