Class: GoogleClient::Contact
- Inherits:
-
Object
- Object
- GoogleClient::Contact
- Defined in:
- lib/google_client/contact.rb
Instance Attribute Summary collapse
-
#email ⇒ Object
Returns the value of attribute email.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#phone_number ⇒ Object
Returns the value of attribute phone_number.
-
#user ⇒ Object
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Contact
constructor
A new instance of Contact.
- #save ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Contact
Returns a new instance of Contact.
11 12 13 14 15 16 17 |
# File 'lib/google_client/contact.rb', line 11 def initialize(params = {}) @id = params[:id] @name = params[:name] @email = params[:email] @phone_number = params[:phone_number] @user = params[:user] end |
Instance Attribute Details
#email ⇒ Object
Returns the value of attribute email.
7 8 9 |
# File 'lib/google_client/contact.rb', line 7 def email @email end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/google_client/contact.rb', line 5 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/google_client/contact.rb', line 6 def name @name end |
#phone_number ⇒ Object
Returns the value of attribute phone_number.
8 9 10 |
# File 'lib/google_client/contact.rb', line 8 def phone_number @phone_number end |
#user ⇒ Object
Returns the value of attribute user.
9 10 11 |
# File 'lib/google_client/contact.rb', line 9 def user @user end |
Class Method Details
.build_contact(data, user = nil) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/google_client/contact.rb', line 29 def build_contact(data, user = nil) id = begin data["id"]["$t"].split("base/").last rescue nil end name = begin data["title"]["$t"].split("full/").last rescue "" end email = begin data["gd$email"].collect { |address| address.select { |item| item["address"] }.values }.flatten rescue [] end phone_number = begin data["gd$phoneNumber"].collect { |number| number.select { |item| item["$t"] }.values }.flatten rescue [] end Contact.new({:name => name, :email => email, :phone_number => phone_number, :user => user}) end |
Instance Method Details
#save ⇒ Object
24 25 26 |
# File 'lib/google_client/contact.rb', line 24 def save end |
#to_s ⇒ Object
19 20 21 |
# File 'lib/google_client/contact.rb', line 19 def to_s "#{self.class.name} => { name: #{@name}, email: #{@email}, :phone_number => #{@phone_number} }" end |