class SgPostcode::ResponseBuilder::JsonOutput
Public Instance Methods
data()
click to toggle source
digg(key_path)
click to toggle source
Get value from a key path
@params: key_path - array
@return value of a keypath
@example
@raw_data = 'results' => [ { 'address' => [ { 'short_name' => '1' } ] } ] so the key_path will be keypath = ['address', 0, 'short_name'] response = SgPostcode::ResponseBuilder::JsonOutput.new(@raw_data) response.data
# 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