Class: Foursquare::Checkin

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(foursquare, json) ⇒ Checkin

Returns a new instance of Checkin.



5
6
7
# File 'lib/foursquare/checkin.rb', line 5

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

Instance Attribute Details

#jsonObject (readonly)

Returns the value of attribute json.



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

def json
  @json
end

Instance Method Details

#created_atObject



26
27
28
# File 'lib/foursquare/checkin.rb', line 26

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

#fetchObject



13
14
15
16
# File 'lib/foursquare/checkin.rb', line 13

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

#idObject



9
10
11
# File 'lib/foursquare/checkin.rb', line 9

def id
  @json["id"]
end

#mayor?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/foursquare/checkin.rb', line 34

def mayor?
  @json["isMayor"]
end

#shoutObject



30
31
32
# File 'lib/foursquare/checkin.rb', line 30

def shout
  @json["shout"]
end

#shout?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/foursquare/checkin.rb', line 22

def shout?
  type == "shout"
end

#timezoneObject



38
39
40
# File 'lib/foursquare/checkin.rb', line 38

def timezone
  @json["timeZone"]
end

#typeObject



18
19
20
# File 'lib/foursquare/checkin.rb', line 18

def type
  @json["type"]
end

#user(full = false) ⇒ Object



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

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



42
43
44
# File 'lib/foursquare/checkin.rb', line 42

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