Class: TicketMaster

Inherits:
Object
  • Object
show all
Defined in:
lib/ticketmaster.rb,
lib/ticketmaster.rb

Overview

This is the TicketMaster class

Defined Under Namespace

Modules: Provider Classes: Authenticator, Exception

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(system = nil, authentication = nil) ⇒ TicketMaster

This initializes the TicketMaster instance and prepares the provider If called without any arguments, it conveniently tries searching for the information in ~/.ticketmaster.yml See the documentation for more information on the format of that file.

What it DOES NOT do is auto-require the provider…so make sure you have the providers required.



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/ticketmaster.rb', line 36

def initialize(system = nil, authentication = nil)
  if system.nil? or authentication.nil?
    require 'yaml'
    data = YAML.load_file File.expand_path(ENV['TICKETMASTER_CONFIG'] || '~/.ticketmaster.yml')
    system = system.nil? ? data['default'] || data.first.first : system.to_s
    authentication = data[system]['authentication'] if authentication.nil? and data[system]['authentication']
  end
  self.extend TicketMaster::Provider.const_get(system.to_s.capitalize)
  authorize authentication
  @symbol = system.to_sym
  @provider = TicketMaster::Provider.const_get(system.to_s.capitalize)
end

Instance Attribute Details

#default_projectObject

Returns the value of attribute default_project.



28
29
30
# File 'lib/ticketmaster.rb', line 28

def default_project
  @default_project
end

#providerObject (readonly)

Returns the value of attribute provider.



27
28
29
# File 'lib/ticketmaster.rb', line 27

def provider
  @provider
end

#symbolObject (readonly)

Returns the value of attribute symbol.



27
28
29
# File 'lib/ticketmaster.rb', line 27

def symbol
  @symbol
end

Instance Method Details

#authorize(authentication = {}) ⇒ Object

Providers should over-write this method



50
51
52
# File 'lib/ticketmaster.rb', line 50

def authorize(authentication = {})
  raise TicketMaster::Exception.new("This method must be reimplemented in the provider")
end