Class: Foursquare::Checkin

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

Instance Method Summary collapse

Constructor Details

#initialize(foursquare, json) ⇒ Checkin

Returns a new instance of Checkin.



3
4
5
# File 'lib/foursquare/checkin.rb', line 3

def initialize(foursquare, json)
  @foursquare, @json = foursquare, json
end

Instance Method Details

#created_atObject



24
25
26
# File 'lib/foursquare/checkin.rb', line 24

def created_at
  Time.at(@json["createdAt"].to_i)
end

#fetchObject



11
12
13
14
# File 'lib/foursquare/checkin.rb', line 11

def fetch
  @json = @foursquare.get("checkins/#{id}")["checkin"]
  self
end

#idObject



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

def id
  @json["id"]
end

#mayor?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/foursquare/checkin.rb', line 32

def mayor?
  @json["isMayor"]
end

#shoutObject



28
29
30
# File 'lib/foursquare/checkin.rb', line 28

def shout
  @json["shout"]
end

#shout?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/foursquare/checkin.rb', line 20

def shout?
  type == "shout"
end

#timezoneObject



36
37
38
# File 'lib/foursquare/checkin.rb', line 36

def timezone
  @json["timeZone"]
end

#typeObject



16
17
18
# File 'lib/foursquare/checkin.rb', line 16

def type
  @json["type"]
end

#user(full = false) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'lib/foursquare/checkin.rb', line 44

def user(full=false)
  fetch unless @json["user"]

  if full
    @foursquare.users.find(@json["user"]["id"])
  else
    Foursquare::User.new(@foursquare, @json["user"])
  end
end

#venueObject



40
41
42
# File 'lib/foursquare/checkin.rb', line 40

def venue
  @json["venue"] && Foursquare::Venue.new(@foursquare, @json["venue"])
end