Class: GoogleR::Calendar

Inherits:
Object
  • Object
show all
Defined in:
lib/google_r/calendar.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



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

def description
  @description
end

#etagObject

Returns the value of attribute etag.



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

def etag
  @etag
end

#google_idObject

Returns the value of attribute google_id.



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

def google_id
  @google_id
end

#summaryObject

Returns the value of attribute summary.



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

def summary
  @summary
end

#time_zoneObject

Returns the value of attribute time_zone.



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

def time_zone
  @time_zone
end

Class Method Details

.api_headersObject



10
11
12
13
14
15
# File 'lib/google_r/calendar.rb', line 10

def self.api_headers
  {
    'GData-Version' => '3.0',
    'Content-Type' => 'application/json',
  }
end

.from_json(json, *attrs) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/google_r/calendar.rb', line 29

def self.from_json(json, *attrs)
  if json["kind"] == "calendar#calendar" || json["kind"] == "calendar#calendarListEntry"
    calendar = self.new
    calendar.google_id = json["id"]
    calendar.etag = json["etag"]
    calendar.summary = json["summary"]
    calendar.description = json["description"]
    calendar.time_zone = json["timeZone"]
    calendar
  else
    raise "Not implemented:\n#{json.inspect}"
  end
end

.pathObject



17
18
19
# File 'lib/google_r/calendar.rb', line 17

def self.path
  "/calendar/v3/users/me/calendarList"
end

.urlObject



6
7
8
# File 'lib/google_r/calendar.rb', line 6

def self.url
  "https://www.googleapis.com"
end

Instance Method Details

#new?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/google_r/calendar.rb', line 55

def new?
  self.google_id.nil?
end

#pathObject



21
22
23
24
25
26
27
# File 'lib/google_r/calendar.rb', line 21

def path
  if new?
    "/calendar/v3/calendars"
  else
    "/calendar/v3/calendars/#{google_id}"
  end
end

#to_google(yajl_opts = {}) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/google_r/calendar.rb', line 43

def to_google(yajl_opts = {})
  hash = {
    "kind" => "calendar#calendar",
  }
  hash["etag"] = etag if etag
  hash["id"] = google_id if google_id
  hash["summary"] = summary if summary
  hash["description"] = description if description
  hash["timeZone"] = time_zone if time_zone
  Yajl::Encoder.encode(hash, yajl_opts)
end