Class: GoogleContactsApi::Result
- Inherits:
-
Hashie::Mash
- Object
- Hashie::Mash
- GoogleContactsApi::Result
- Defined in:
- lib/google_contacts_api/result.rb
Overview
Base class for Group and Contact
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
These are the accessors we can write :id, :title, :updated, :content.
Instance Method Summary collapse
-
#categories ⇒ Object
Returns the array of categories, as category is an array for Hashie.
- #content ⇒ Object
- #deleted? ⇒ Boolean
-
#etag ⇒ Object
TODO: Conditional retrieval? There might not be an etag in the JSON representation, there is in the XML representation.
- #id ⇒ Object
-
#initialize(source_hash = nil, default = nil, api = nil, &blk) ⇒ Result
constructor
Populate from a single result Hash/Hashie.
- #inspect ⇒ Object
- #title ⇒ Object
- #updated ⇒ Object
Constructor Details
#initialize(source_hash = nil, default = nil, api = nil, &blk) ⇒ Result
Populate from a single result Hash/Hashie
14 15 16 17 |
# File 'lib/google_contacts_api/result.rb', line 14 def initialize(source_hash = nil, default = nil, api = nil, &blk) @api = api if api super(source_hash, default, &blk) end |
Instance Attribute Details
#api ⇒ Object (readonly)
These are the accessors we can write :id, :title, :updated, :content
12 13 14 |
# File 'lib/google_contacts_api/result.rb', line 12 def api @api end |
Instance Method Details
#categories ⇒ Object
Returns the array of categories, as category is an array for Hashie. There is a scheme and a term.
46 47 48 |
# File 'lib/google_contacts_api/result.rb', line 46 def categories category end |
#content ⇒ Object
34 35 36 37 |
# File 'lib/google_contacts_api/result.rb', line 34 def content _content = self["content"] _content ? _content["$t"] : nil end |
#deleted? ⇒ Boolean
50 51 52 |
# File 'lib/google_contacts_api/result.rb', line 50 def deleted? raise NotImplementedError end |
#etag ⇒ Object
TODO: Conditional retrieval? There might not be an etag in the JSON representation, there is in the XML representation
21 22 |
# File 'lib/google_contacts_api/result.rb', line 21 def etag end |
#id ⇒ Object
24 25 26 27 |
# File 'lib/google_contacts_api/result.rb', line 24 def id _id = self["id"] _id ? _id["$t"] : nil end |
#inspect ⇒ Object
54 55 56 |
# File 'lib/google_contacts_api/result.rb', line 54 def inspect "<#{self.class}: #{title}>" end |
#title ⇒ Object
29 30 31 32 |
# File 'lib/google_contacts_api/result.rb', line 29 def title _title = self["title"] _title ? _title["$t"] : nil end |
#updated ⇒ Object
39 40 41 42 |
# File 'lib/google_contacts_api/result.rb', line 39 def updated _updated = self["updated"] _updated ? DateTime.parse(_updated["$t"]) : nil end |