Class: Grubby::JsonParser
- Inherits:
-
Mechanize::File
- Object
- Mechanize::File
- Grubby::JsonParser
- Defined in:
- lib/grubby/json_parser.rb
Instance Attribute Summary collapse
-
#json ⇒ Hash, Array
readonly
The parsed JSON data.
-
#mech ⇒ Mechanize?
The Mechanize agent used to make the request.
Class Method Summary collapse
-
.json_parse_options ⇒ Hash
Returns the options to use when parsing JSON.
-
.json_parse_options=(options) ⇒ Object
Sets the options to use when parsing JSON.
Instance Method Summary collapse
-
#initialize(uri = nil, response = nil, body = nil, code = nil, mech = nil) ⇒ JsonParser
constructor
A new instance of JsonParser.
Constructor Details
#initialize(uri = nil, response = nil, body = nil, code = nil, mech = nil) ⇒ JsonParser
Returns a new instance of JsonParser.
39 40 41 42 43 |
# File 'lib/grubby/json_parser.rb', line 39 def initialize(uri = nil, response = nil, body = nil, code = nil, mech = nil) @json = body.presence && JSON.parse(body, self.class.) @mech = mech super(uri, response, body, code) end |
Instance Attribute Details
#json ⇒ Hash, Array (readonly)
The parsed JSON data.
32 33 34 |
# File 'lib/grubby/json_parser.rb', line 32 def json @json end |
#mech ⇒ Mechanize?
The Mechanize agent used to make the request.
37 38 39 |
# File 'lib/grubby/json_parser.rb', line 37 def mech @mech end |
Class Method Details
.json_parse_options ⇒ Hash
Returns the options to use when parsing JSON. The returned options Hash is not duped and can be modified directly. Any modifications will be applied to all future parsing.
For information about available options, see JSON.parse.
12 13 14 |
# File 'lib/grubby/json_parser.rb', line 12 def self. ||= JSON..merge(create_additions: false) end |
.json_parse_options=(options) ⇒ Object
Sets the options to use when parsing JSON. The entire options Hash is replaced, and the new value will be applied to all future parsing. To set options individually, see json_parse_options.
For information about available options, see JSON.parse.
25 26 27 |
# File 'lib/grubby/json_parser.rb', line 25 def self.=() = end |