Class: Caly::Account

Inherits:
Object
  • Object
show all
Defined in:
lib/caly/account.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(provider, token) ⇒ Account

Returns a new instance of Account.



5
6
7
8
9
10
11
12
# File 'lib/caly/account.rb', line 5

def initialize(provider, token)
  unless Caly::AVAILABLE_PROVIDERS.include?(provider.to_sym)
    raise ArgumentError.new("#{provider} isn't a supported provider.")
  end

  @provider = provider
  @token = token
end

Instance Attribute Details

#providerObject (readonly)

Returns the value of attribute provider.



3
4
5
# File 'lib/caly/account.rb', line 3

def provider
  @provider
end

#tokenObject (readonly)

Returns the value of attribute token.



3
4
5
# File 'lib/caly/account.rb', line 3

def token
  @token
end

Class Method Details

.caly_provider_for(name) ⇒ Object



14
15
16
# File 'lib/caly/account.rb', line 14

def self.caly_provider_for(name)
  Caly::Providers.const_get(Util.classify(name))
end

Instance Method Details

#caly_providerObject



18
19
20
# File 'lib/caly/account.rb', line 18

def caly_provider
  @caly_provider ||= self.class.caly_provider_for(provider).new(token)
end

#list_calendarsObject



22
23
24
# File 'lib/caly/account.rb', line 22

def list_calendars
  caly_provider.list_calendars
end