Class: K8s::JSONParser::Default
- Inherits:
-
Object
- Object
- K8s::JSONParser::Default
- Defined in:
- lib/k8s/json_parser.rb
Overview
Standard library JSON -based JSON-parsing backend
Defined Under Namespace
Classes: LineBufferedIO
Class Method Summary collapse
-
.parse(input) ⇒ Hash, ...
The parsed result.
Instance Method Summary collapse
- #<<(data) ⇒ Object
-
#initialize(&block) ⇒ Default
constructor
Instantiate a streaming parser.
Constructor Details
#initialize(&block) ⇒ Default
Instantiate a streaming parser.
53 54 55 56 57 |
# File 'lib/k8s/json_parser.rb', line 53 def initialize(&block) @parser = LineBufferedIO.new do |data| block.call(JSON.parse(data)) end end |
Class Method Details
.parse(input) ⇒ Hash, ...
Returns the parsed result.
37 38 39 |
# File 'lib/k8s/json_parser.rb', line 37 def self.parse(input) JSON.parse(input) end |
Instance Method Details
#<<(data) ⇒ Object
59 60 61 |
# File 'lib/k8s/json_parser.rb', line 59 def <<(data) @parser << data end |