Class: Twitter::MediaFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/twitter/media_factory.rb

Class Method Summary collapse

Class Method Details

.new(media = {}) ⇒ Twitter::Photo

Instantiates a new media object

Parameters:

Returns:

Raises:

  • (ArgumentError)

    Error raised when supplied argument is missing a 'type' key.



11
12
13
14
15
16
17
18
# File 'lib/twitter/media_factory.rb', line 11

def self.new(media={})
  type = media.delete('type')
  if type
    Twitter.const_get(type.capitalize.to_sym).new(media)
  else
    raise ArgumentError, "argument must have a 'type' key"
  end
end