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.
-
#events ⇒ Array<When::V::Event>
readonly
Calendar に属する Event.
-
#service ⇒ Google::Apis::CalendarV3::CalendarService
readonly
Calendar API のインスタンス.
Class Method Summary collapse
-
.list(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
31 32 33 |
# File 'lib/when_exe/google_api.rb', line 31 def calendar_id @calendar_id end |
#events ⇒ Array<When::V::Event> (readonly)
Calendar に属する Event
37 38 39 |
# File 'lib/when_exe/google_api.rb', line 37 def events @events end |
#service ⇒ Google::Apis::CalendarV3::CalendarService (readonly)
Calendar API のインスタンス
25 26 27 |
# File 'lib/when_exe/google_api.rb', line 25 def service @service end |
Class Method Details
.list(service, calendar_id) ⇒ Object
GoogleAPI の Calendar を生成する
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/when_exe/google_api.rb', line 46 def list(service, calendar_id) events = [] result = service.list_events(calendar_id) loop do events += result.items.map {|event| event.to_h} page_token = result.next_page_token break unless page_token result = service.list_events(calendar_id, page_token: page_token) end calendar = new(events) 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
68 69 70 |
# File 'lib/when_exe/google_api.rb', line 68 def enum_for(*args) When::Parts::Enumerator::Integrated.new(self, @events.map {|event| event.enum_for(*args)}, *args) end |