class LinkedIn::Mash
Coerces LinkedIn
JSON to a nice Ruby hash LinkedIn::Mash
inherits from Hashie::Mash
Public Class Methods
from_json(json_string)
click to toggle source
a simple helper to convert a json string to a Mash
# File lib/linked_in/mash.rb, line 7 def self.from_json(json_string) result_hash = JSON.load(json_string) new(result_hash) end
Public Instance Methods
timestamp()
click to toggle source
# File lib/linked_in/mash.rb, line 21 def timestamp value = self['timestamp'] if value.kind_of? Integer value = value / 1000 if value > 9999999999 Time.at(value) else value end end
to_date()
click to toggle source
returns a Date if we have year, month and day, and no conflicting key
Calls superclass method
# File lib/linked_in/mash.rb, line 13 def to_date if !self.has_key?('to_date') && contains_date_fields? Date.civil(self.year, self.month, self.day) else super end end