Class: When::GoogleAPI::Calendar
- Inherits:
-
Object
- Object
- When::GoogleAPI::Calendar
- Defined in:
- lib/when_exe/google_api.rb
Overview
GoogleAPI の Calendar API v3 に対応した Calendar クラス
Instance Attribute Summary collapse
-
#calendar_id ⇒ String
readonly
calendar の id.
-
#client ⇒ Google::APIClient
readonly
APIClient のインスタンス.
-
#events ⇒ Array<When::V::Event>
readonly
Calendar に属する Event.
-
#service ⇒ Google::APIClient::API
readonly
Calendar API のインスタンス.
Class Method Summary collapse
-
.list(client, service, calendar_id) ⇒ Object
GoogleAPI の Calendar を生成する.
Instance Method Summary collapse
-
#enum_for(*args) ⇒ Enumerator
(also: #to_enum)
イベントを順に取り出す enumerator.
-
#initialize(events) ⇒ Calendar
constructor
Calendar インスタンスを生成する.
Constructor Details
Instance Attribute Details
#calendar_id ⇒ String (readonly)
calendar の id
36 37 38 |
# File 'lib/when_exe/google_api.rb', line 36 def calendar_id @calendar_id end |
#client ⇒ Google::APIClient (readonly)
APIClient のインスタンス
24 25 26 |
# File 'lib/when_exe/google_api.rb', line 24 def client @client end |
#events ⇒ Array<When::V::Event> (readonly)
Calendar に属する Event
42 43 44 |
# File 'lib/when_exe/google_api.rb', line 42 def events @events end |
#service ⇒ Google::APIClient::API (readonly)
Calendar API のインスタンス
30 31 32 |
# File 'lib/when_exe/google_api.rb', line 30 def service @service end |
Class Method Details
.list(client, service, calendar_id) ⇒ Object
GoogleAPI の Calendar を生成する
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/when_exe/google_api.rb', line 52 def list(client, service, calendar_id) events = [] result = client.execute({:api_method => service.events.list, :parameters => {'calendarId' => calendar_id}}) loop do events += result.data.items.map {|event| event.to_hash} page_token = result.data.next_page_token break unless page_token result = client.execute({:api_method => service.events.list, :parameters => {'calendarId' => calendar_id, 'pageToken' => page_token}}) end calendar = new(events) calendar.instance_variable_set(:@client, client) calendar.instance_variable_set(:@service, service) calendar.instance_variable_set(:@calendar_id, calendar_id) calendar end |
Instance Method Details
#enum_for(*args) ⇒ Enumerator Also known as: to_enum
イベントを順に取り出す enumerator
78 79 80 |
# File 'lib/when_exe/google_api.rb', line 78 def enum_for(*args) When::Parts::Enumerator::Integrated.new(self, @events.map {|event| event.enum_for(*args)}, *args) end |