Class: SgPostcode::ResponseBuilder::JsonOutput
- Defined in:
- lib/sg_postcode/response/json_output.rb
Instance Attribute Summary
Attributes inherited from Builder
Instance Method Summary collapse
-
#data ⇒ Object
Implement #data from Builder.
-
#digg(key_path) ⇒ Object
Get value from a key path.
Methods inherited from Builder
Constructor Details
This class inherits a constructor from SgPostcode::ResponseBuilder::Builder
Instance Method Details
#data ⇒ Object
Implement #data from Builder
Combine all info fields in Config class to the result
7 8 9 10 11 12 13 14 15 |
# File 'lib/sg_postcode/response/json_output.rb', line 7 def data result = {} Config.fields.each do |key, value| result[key] = digg value end result end |
#digg(key_path) ⇒ Object
Get value from a key path
@params: key_path - array
41 42 43 44 45 |
# File 'lib/sg_postcode/response/json_output.rb', line 41 def digg(key_path) key_path.inject(@raw_data) do |result, key| (result.respond_to?(:[]) && (result[key] || {})) || break end end |