Class: Hangout::Checkin

Inherits:
Object
  • Object
show all
Defined in:
lib/hangout/checkin.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



6
7
8
# File 'lib/hangout/checkin.rb', line 6

def created_at
  @created_at
end

#locationObject (readonly)

Returns the value of attribute location.



7
8
9
# File 'lib/hangout/checkin.rb', line 7

def location
  @location
end

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

#timeObject



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_sObject



31
32
33
# File 'lib/hangout/checkin.rb', line 31

def to_s
  "#{user_name} - #{location} (#{time})"
end