Class: Hangout::Checkin
- Inherits:
-
Object
- Object
- Hangout::Checkin
- Defined in:
- lib/hangout/checkin.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#user_name ⇒ Object
readonly
Returns the value of attribute user_name.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
6 7 8 |
# File 'lib/hangout/checkin.rb', line 6 def created_at @created_at end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
7 8 9 |
# File 'lib/hangout/checkin.rb', line 7 def location @location end |
#user_name ⇒ Object (readonly)
Returns the value of attribute user_name.
5 6 7 |
# File 'lib/hangout/checkin.rb', line 5 def user_name @user_name end |
Class Method Details
.parse(checkin) ⇒ Object
9 10 11 |
# File 'lib/hangout/checkin.rb', line 9 def self.parse checkin new.parse checkin end |
Instance Method Details
#parse(checkin) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/hangout/checkin.rb', line 13 def parse(checkin) begin @user_name = [checkin.user.firstName, checkin.user.lastName].join " " @created_at = Time.at(checkin.createdAt) @location = checkin.venue.name rescue NoMethodError => e raise InvalidCheckinError end self end |
#time ⇒ Object
25 26 27 28 29 |
# File 'lib/hangout/checkin.rb', line 25 def time hour = @created_at.hour.to_s.rjust(2, '0') mins = @created_at.min.to_s.rjust(2, '0') "#{hour}:#{mins}" end |
#to_s ⇒ Object
31 32 33 |
# File 'lib/hangout/checkin.rb', line 31 def to_s "#{user_name} - #{location} (#{time})" end |