Class: GoogleContactsApi::Result

Inherits:
Hashie::Mash
  • Object
show all
Defined in:
lib/google_contacts_api/result.rb

Overview

Base class for Group and Contact

Direct Known Subclasses

Contact, Group

Instance Attribute Summary collapse

Instance Method Summary collapse

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

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

#categoriesObject

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

#contentObject



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

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


50
51
52
# File 'lib/google_contacts_api/result.rb', line 50

def deleted?
  raise NotImplementedError
end

#etagObject

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

#idObject



24
25
26
27
# File 'lib/google_contacts_api/result.rb', line 24

def id
  _id = self["id"]
  _id ? _id["$t"] : nil
end

#inspectObject



54
55
56
# File 'lib/google_contacts_api/result.rb', line 54

def inspect
  "<#{self.class}: #{title}>"
end

#titleObject



29
30
31
32
# File 'lib/google_contacts_api/result.rb', line 29

def title
  _title = self["title"]
  _title ? _title["$t"] : nil
end

#updatedObject



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