geeksam / spicy-proton

Generate a random English adjective-noun word pair in Ruby

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Spicy::Proton

Generate a random English adjective-noun word pair. Works with Ruby 1.9.x and newer.

Gem Version Build Status

Quick Start

gem install spicy-proton

require 'spicy-proton'

puts Spicy::Proton.pair
# => "decadent-inquisition"

Usage

When generating single or infrequent specimens, class methods are faster and use less memory.

require 'spicy-proton'

Spicy::Proton.adjective             # => "extreme"
Spicy::Proton.noun                  # => "loan"
Spicy::Proton.pair                  # => "opportune-spacesuit"
Spicy::Proton.pair(':')             # => "hip:squash"
Spicy::Proton.format('%a/%n')       # => "slippery/rattler"

# With length constraints.
Spicy::Proton.noun(min: 10)         # => "translucence"
Spicy::Proton.adjective(max: 5)     # => "foamy"
Spicy::Proton.noun(min: 5, max: 7)  # => "target"
Spicy::Proton.adjective(length: 8)  # => "medieval"

When generating multiple specimens, instance methods are faster. The instance keeps the word corpus in memory. The instance methods are the same as their class method counterparts.

require 'spicy-proton'

generator = Spicy::Proton.new
1000.times do 
  generator.adjective
  generator.noun(min: 7)
  generator.pair
  generator.pair('.')
  generator.format('%a-%c-%n')
end

Instances give you access to the raw word lists as well:

generator.adjectives    # => ["dreadful", "methodist", "necessary", "tough", ...]
generator.nouns         # => ["rustling", "fiance", "infield", "chatter", ...]

License

Copyright © 2017 Chris Schmich
MIT License. See LICENSE for details.

About

Generate a random English adjective-noun word pair in Ruby

License:MIT License


Languages

Language:Ruby 96.3%Language:Makefile 3.7%