Class: K8s::JSONParser::Yajl
- Inherits:
-
Object
- Object
- K8s::JSONParser::Yajl
- Defined in:
- lib/k8s/json_parser/yajl.rb
Overview
Yajl JSON-parsing backend, with the native extension it’s faster than the pure-ruby standard library JSON-parser.
To use install, add ‘gem ’yajl-ruby’‘ to your gemfile and require this class: `require ’k8s/json_parser/yajl’‘
Class Method Summary collapse
-
.parse(input) ⇒ Hash, ...
The parsed result.
Instance Method Summary collapse
-
#<<(data) ⇒ Object
The block passed to #new will be executed for each complete document.
-
#initialize(&block) ⇒ Yajl
constructor
Instantiate a streaming parser.
Constructor Details
#initialize(&block) ⇒ Yajl
Instantiate a streaming parser.
29 30 31 32 33 |
# File 'lib/k8s/json_parser/yajl.rb', line 29 def initialize(&block) @parser = ::Yajl::Parser.new.tap do |parser| parser.on_parse_complete = block end end |
Class Method Details
.parse(input) ⇒ Hash, ...
Returns the parsed result.
13 14 15 |
# File 'lib/k8s/json_parser/yajl.rb', line 13 def self.parse(input) ::Yajl::Parser.parse(input) end |
Instance Method Details
#<<(data) ⇒ Object
The block passed to #new will be executed for each complete document
37 38 39 |
# File 'lib/k8s/json_parser/yajl.rb', line 37 def <<(data) @parser << data end |