Class: Gaah::Calendar::Event

Inherits:
ApiModel show all
Defined in:
lib/gaah/calendar/event.rb

Instance Attribute Summary collapse

Attributes inherited from ApiModel

#id

Instance Method Summary collapse

Methods inherited from ApiModel

#==, batch_create

Constructor Details

#initialize(json) ⇒ Event

Returns a new instance of Event.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/gaah/calendar/event.rb', line 6

def initialize(json)
  store_json(json)

  @id           = json['id']
  @ical_uid     = json['iCalUID']
  @updated      = Time.parse(json['updated'])
  @summary      = json['summary'].to_s
  @description  = json['description'].to_s
  @location     = json['location'].to_s
  @creator      = Who.new(json['creator']) if json['creator']
  @when         = parse_when
  @attendees    = parse_attendees
  @transparency = json['transparency'].to_s
  @visibility   = json['visibility'] || 'default'
  @organizer    = Who.new(json['organizer']) if json['organizer']
  @sequence     = json['sequence']
  @status       = json['status']
  @url          = json['htmlLink']
end

Instance Attribute Details

#attendeesObject (readonly)

Returns the value of attribute attendees.



4
5
6
# File 'lib/gaah/calendar/event.rb', line 4

def attendees
  @attendees
end

#creatorObject (readonly)

Returns the value of attribute creator.



4
5
6
# File 'lib/gaah/calendar/event.rb', line 4

def creator
  @creator
end

#descriptionObject (readonly)

Returns the value of attribute description.



4
5
6
# File 'lib/gaah/calendar/event.rb', line 4

def description
  @description
end

#ical_uidObject (readonly)

Returns the value of attribute ical_uid.



4
5
6
# File 'lib/gaah/calendar/event.rb', line 4

def ical_uid
  @ical_uid
end

#locationObject (readonly)

Returns the value of attribute location.



4
5
6
# File 'lib/gaah/calendar/event.rb', line 4

def location
  @location
end

#organizerObject (readonly)

Returns the value of attribute organizer.



4
5
6
# File 'lib/gaah/calendar/event.rb', line 4

def organizer
  @organizer
end

#sequenceObject (readonly)

Returns the value of attribute sequence.



4
5
6
# File 'lib/gaah/calendar/event.rb', line 4

def sequence
  @sequence
end

#statusObject (readonly)

Returns the value of attribute status.



4
5
6
# File 'lib/gaah/calendar/event.rb', line 4

def status
  @status
end

#summaryObject (readonly)

Returns the value of attribute summary.



4
5
6
# File 'lib/gaah/calendar/event.rb', line 4

def summary
  @summary
end

#transparencyObject (readonly)

Returns the value of attribute transparency.



4
5
6
# File 'lib/gaah/calendar/event.rb', line 4

def transparency
  @transparency
end

#updatedObject (readonly)

Returns the value of attribute updated.



4
5
6
# File 'lib/gaah/calendar/event.rb', line 4

def updated
  @updated
end

#urlObject (readonly)

Returns the value of attribute url.



4
5
6
# File 'lib/gaah/calendar/event.rb', line 4

def url
  @url
end

#visibilityObject (readonly)

Returns the value of attribute visibility.



4
5
6
# File 'lib/gaah/calendar/event.rb', line 4

def visibility
  @visibility
end

#whenObject (readonly)

Returns the value of attribute when.



4
5
6
# File 'lib/gaah/calendar/event.rb', line 4

def when
  @when
end

Instance Method Details

#authorObject

V2 -> V3



49
# File 'lib/gaah/calendar/event.rb', line 49

def author;  creator;     end

#contentObject



50
# File 'lib/gaah/calendar/event.rb', line 50

def content; description; end

#marshal_dumpObject



55
56
57
58
59
# File 'lib/gaah/calendar/event.rb', line 55

def marshal_dump
  [@id, nil, @updated, @summary, @description, @location, @creator, @when,
   @attendees, @transparency, @visibility, @ical_uid, @organizer,
   @sequence, @status, @url]
end

#marshal_load(array) ⇒ Object



61
62
63
64
65
# File 'lib/gaah/calendar/event.rb', line 61

def marshal_load(array)
  @id, _, @updated, @summary, @description, @location, @creator, @when,
    @attendees, @transparency, @visibility, @ical_uid, @organizer,
    @sequence, @status, @url = array
end

#resourcesObject



44
45
46
# File 'lib/gaah/calendar/event.rb', line 44

def resources
  who.select(&:is_resource?)
end

#titleObject



51
# File 'lib/gaah/calendar/event.rb', line 51

def title;   summary;     end

#to_json(*args) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/gaah/calendar/event.rb', line 26

def to_json(*args)
  {
    id:           @id,
    updated:      @updated,
    summary:      @summary,
    description:  @description,
    location:     @location,
    creator:      @creator,
    when:         @when,
    attendees:    @attendees,
    transparency: @transparency,
    visibility:   @visibility,
    status:       @status,
    url:          @url,
    resources:    resources,
  }.to_json
end

#whereObject



52
# File 'lib/gaah/calendar/event.rb', line 52

def where;   location;    end

#whoObject



53
# File 'lib/gaah/calendar/event.rb', line 53

def who;     attendees;   end