Class: SlideShare::Base

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/slide_share/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash_or_yaml) ⇒ Base

Returns an instance of SlideShare::Base. Takes the following options:

  • :api_key - SlideShare API key

  • :shared_pass - SlideShared shared secret

Alternatively, this method may take the path to a YAML file containing this data. Examples (of both):

# Using the options hash
@slideshare = SlideShare::Base.new(:api_key => "4815162342", :shared_secret => "dharma")
# Using the YAML file
@slideshare = SlideShare::Base.new("path/to/file.yml")


23
24
25
26
27
28
29
30
31
# File 'lib/slide_share/base.rb', line 23

def initialize(hash_or_yaml)
  config = hash_or_yaml.is_a?(Hash) ? hash_or_yaml :
    YAML.load_file(hash_or_yaml)
  self.api_key = config[:api_key]
  self.shared_secret = config[:shared_secret]
  unless api_key && shared_secret
    raise ArgumentError, "Configuration must have values for :api_key and :shared_secret"
  end
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



9
10
11
# File 'lib/slide_share/base.rb', line 9

def api_key
  @api_key
end

#shared_secretObject

Returns the value of attribute shared_secret.



9
10
11
# File 'lib/slide_share/base.rb', line 9

def shared_secret
  @shared_secret
end

Instance Method Details

#slideshowsObject

OO abstraction for SlideShare::Slideshow namespace. Example usage:

@slideshare = SlideShare::Base.new("path/to/file.yml")
@slideshow = @slideshare.slideshows.find(815)

This is recommended over initializing and accessing a SlideShare::Slideshow object directly.



40
41
42
# File 'lib/slide_share/base.rb', line 40

def slideshows
  @slideshow ||= Slideshows.new(self)
end