Method: FbGraph::Event#initialize

Defined in:
lib/fb_graph/event.rb

#initialize(identifier, attributes = {}) ⇒ Event

Returns a new instance of Event.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/fb_graph/event.rb', line 15

def initialize(identifier, attributes = {})
  super
  if (owner = attributes[:owner])
    @owner = User.new(owner[:id], owner)
  end
  @name        = attributes[:name]
  @description = attributes[:description]
  @location    = attributes[:location]
  @privacy     = attributes[:privacy]
  if (start_time = attributes[:start_time])
    @start_time = case start_time
    when String
      Time.parse(start_time)
    when Integer
      Time.at(start_time)
    end
  end
  if (end_time = attributes[:end_time])
    @end_time = case end_time
    when String
      Time.parse(end_time)
    when Integer
      Time.at(end_time)
    end
  end
  if venue = attributes[:venue]
    @venue = if venue[:id]
      Page.new(venue[:id], venue)
    else
      Venue.new(venue)
    end
  end
  if attributes[:updated_time]
    @updated_time = Time.parse(attributes[:updated_time]).utc
  end
  @ticket_uri = attributes[:ticket_uri]
end