Class: Aliyun::ESS::Parsing::JsonParser

Inherits:
Hash
  • Object
show all
Includes:
Typecasting
Defined in:
lib/aliyun/ess/parsing.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Typecasting

#typecast, #typecast_hash

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

#bodyObject (readonly)

Returns the value of attribute body.



34
35
36
# File 'lib/aliyun/ess/parsing.rb', line 34

def body
  @body
end

#codeObject (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