Class: Aliyun::ESS::Parsing::JsonParser
- Inherits:
-
Hash
- Object
- Hash
- Aliyun::ESS::Parsing::JsonParser
- Includes:
- Typecasting
- Defined in:
- lib/aliyun/ess/parsing.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Instance Method Summary collapse
-
#initialize(body) ⇒ JsonParser
constructor
A new instance of JsonParser.
- #slice(*keys) ⇒ Object
Methods included from Typecasting
Constructor Details
#initialize(body) ⇒ JsonParser
Returns a new instance of JsonParser.
36 37 38 39 40 41 42 43 |
# File 'lib/aliyun/ess/parsing.rb', line 36 def initialize(body) @body = body unless body.strip.empty? parse typecast_json_parsed set_code end end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
34 35 36 |
# File 'lib/aliyun/ess/parsing.rb', line 34 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
34 35 36 |
# File 'lib/aliyun/ess/parsing.rb', line 34 def code @code end |
Instance Method Details
#slice(*keys) ⇒ Object
45 46 47 48 |
# File 'lib/aliyun/ess/parsing.rb', line 45 def slice(*keys) keys.map! { |key| key.to_s } keys.inject({}) { |hash, k| hash[k] = self[k] if has_key?(k); hash } end |