Class: Visit

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/saw/visit.rb

Instance Method Summary collapse

Instance Method Details

#ends_withObject



26
27
28
# File 'lib/saw/visit.rb', line 26

def ends_with
  hits.last
end

#lastsObject



30
31
32
# File 'lib/saw/visit.rb', line 30

def lasts
  Saw::Util.time_diff created_at, ends_with.created_at if ends_with
end

#starts_withObject



22
23
24
# File 'lib/saw/visit.rb', line 22

def starts_with
  hits.first
end

#titleObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/saw/visit.rb', line 9

def title
  user_name = ''

  %w(name first_name username email).each do |attr|
    if user.respond_to? attr
      user_name = user.send attr
      break
    end
  end

  "#{user_name}(#{lasts}) on #{created_at.strftime('%b %-d %Y, %l %P')}"
end