Class: OpenSocial::Person
Instance Method Summary collapse
-
#initialize(json) ⇒ Person
constructor
Initializes the Person based on the provided json fragment.
-
#long_name ⇒ Object
Returns the complete name of the Person, to the best ability, given available fields.
-
#short_name ⇒ Object
Returns the first name or nickname of the Person, to the best ability, given available fields.
Methods inherited from Base
Constructor Details
#initialize(json) ⇒ Person
Initializes the Person based on the provided json fragment. If no JSON is provided, an empty object (with no attributes) is created.
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/opensocial/person.rb', line 40 def initialize(json) if json json.each do |key, value| proper_key = key.snake_case begin self.send("#{proper_key}=", value) rescue NoMethodError add_attr(proper_key) self.send("#{proper_key}=", value) end end end end |
Instance Method Details
#long_name ⇒ Object
Returns the complete name of the Person, to the best ability, given available fields.
56 57 58 59 60 61 62 63 64 |
# File 'lib/opensocial/person.rb', line 56 def long_name if @name && @name['givenName'] && @name['familyName'] return @name['givenName'] + ' ' + @name['familyName'] elsif @nickname return @nickname else return '' end end |
#short_name ⇒ Object
Returns the first name or nickname of the Person, to the best ability, given available fields.
68 69 70 71 72 73 74 75 76 |
# File 'lib/opensocial/person.rb', line 68 def short_name if @name && @name['givenName'] return @name['givenName'] elsif @nickname return @nickname else return '' end end |