Class: ApiHammer::Filtration::Json
- Defined in:
- lib/api_hammer/filtration/json.rb
Overview
This class implements the JSON filterer that is used to filter a JSON string
Instance Method Summary collapse
- #filter ⇒ Object
-
#initialize(source, opts = {}) ⇒ Json
constructor
Creates a new instance for the string source.
Constructor Details
#initialize(source, opts = {}) ⇒ Json
Creates a new instance for the string source.
11 12 13 14 |
# File 'lib/api_hammer/filtration/json.rb', line 11 def initialize(source, opts = {}) super source @options = opts end |
Instance Method Details
#filter ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/api_hammer/filtration/json.rb', line 16 def filter reset obj = '' while !eos? && scan_result(obj, IGNORE) end if eos? raise ParserError, "source did not contain any JSON!" else value = filter_value if value == UNPARSED raise ParserError, "source did not contain any JSON!" else obj << value end end obj end |