Module Amazon
In: lib/amazon/aws/cache.rb
lib/amazon/aws/shoppingcart.rb
lib/amazon/aws/search.rb
lib/amazon/locale.rb
lib/amazon/aws.rb
lib/amazon.rb

$Id: amazon.rb,v 1.33 2010/03/19 17:20:46 ianmacd Exp $

Methods

Classes and Modules

Module Amazon::AWS
Module Amazon::Locale
Class Amazon::AmazonError
Class Amazon::Config

Constants

NAME = 'Ruby/Amazon'

Public Class methods

Prints debugging messages and works like printf, except that it prints only when Ruby is run with the -d switch.

[Source]

# File lib/amazon.rb, line 24
  def Amazon.dprintf(format='', *args)
    $stderr.printf( format + "\n", *args ) if $DEBUG
  end

Convert a string from CamelCase to ruby_case.

[Source]

# File lib/amazon.rb, line 42
  def Amazon.uncamelise(string)
    # Avoid modifying by reference.
    #
    string = string.dup

    # Don't mess with string if all caps.
    #
    if string =~ /[a-z]/
      string.gsub!( /(.+?)(([A-Z][a-z]|[A-Z]+$))/, "\\1_\\2" )
    end

    # Convert to lower case.
    #
    string.downcase
  end

Encode a string, such that it is suitable for HTTP transmission.

[Source]

# File lib/amazon.rb, line 30
  def Amazon.url_encode(string)

    # Shamelessly plagiarised from Wakou Aoyama's cgi.rb, but then altered
    # slightly to please AWS.
    #
    string.gsub( /([^a-zA-Z0-9_.~-]+)/ ) do
      '%' + $1.unpack( 'H2' * $1.bytesize ).join( '%' ).upcase
    end
  end

[Validate]