Sha256: fccc4e5a24bb918ca9ff55a898eaff954782b7c4c9582dd5313f40eb42d02617

Contents?: true

Size: 1.41 KB

Versions: 5

Compression:

Stored size: 1.41 KB

Contents

class Fab

  NAME_CHARS = "aabcdeeefghiijklmnoopqrrssttuuvwxyz".split(//)
  NOTE_CHARS = "aabcdeeefghiijklmnoopqrrssttuuvwxyz     ..,,;;-+'*".split(//)

  # Fab a random name.
  #
  # Options:
  #
  #  * chars: NAME_CHARS
  #  * size: rand(10..30) [actual size may be less because we strip the string]
  #
  # @returns [String] a random name
  #
  def name(options = {})
    (options[:chars] || NAME_CHARS).sample(options[:size] || rand(10..30)).join.strip
  end

  # Fab a random note.
  #
  # Options:
  #
  #  * chars: NOTE_CHARS
  #  * size: rand(1..200) [actual size may be less because we strip the string]
  #
  # @returns [String] a random name
  #
  def note(options = {})
    (options[:chars] || NOTE_CHARS).sample(options[:size] || rand(1..200)).join.strip
  end

  # Fab a random note.
  #
  # Options:
  #
  #  * chars: NOTE_CHARS
  #  * size: rand(20..200) [actual size may be less because we strip the string]
  #
  # @returns [String] a random description
  #
  def description(options = {})
    (options[:chars] || NOTE_CHARS).sample(options[:size] || rand(20..200)).join.strip
  end

  # Fab a random lorem ipsum string.
  #
  # Options:
  #
  #  * chars: NOTE_CHARS
  #  * size: rand(20..200) [actual size may be less because we strip the string]
  #
  # @returns [String] a random description
  #
  def lorem(options = {})
    (options[:chars] || NOTE_CHARS).sample(options[:size] || rand(20..200)).join.strip
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

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