Sha256: 99b49efc68971215d74c64922d7a629712540c095cf347b8dab51aafa41f4838

Contents?: true

Size: 580 Bytes

Versions: 5

Compression:

Stored size: 580 Bytes

Contents

class Fab

  # Fab a random content type part e.g. "image/jpeg".
  #
  # Options:
  #
  #   * chars: a..z
  #   * size: rand(1..20) [per part]
  #
  # @returns [String] a content type
  #
  def content_type(options = {})
    "#{content_type_part(options)}/#{content_type_part(options)}"
  end

  # Fab a random content type part e.g. "image".
  #
  # Options:
  #
  #   * chars: a..z
  #   * size: rand(1..20)
  #
  # @returns [String] a content type part
  #
  def content_type_part(options = {})
    (options[:chars] || AZ).sample(options[:size] || rand(1..20)).join
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sixarm_ruby_fab-1.1.0 lib/sixarm_ruby_fab/mime.rb
sixarm_ruby_fab-1.0.4 lib/sixarm_ruby_fab/mime.rb
sixarm_ruby_fab-1.0.2 lib/sixarm_ruby_fab/mime.rb
sixarm_ruby_fab-1.0.1 lib/sixarm_ruby_fab/mime.rb
sixarm_ruby_fab-1.0.0 lib/sixarm_ruby_fab/mime.rb