Tekido
Tekido
is a module that generates various random value.
Installation
Add this line to your application's Gemfile:
gem 'tekido'
And then execute:
$ bundle
Or install it yourself as:
$ gem install tekido
Usage
Tekido
has below methods. (All methods are dependent on Kernel.rand
)
.yes?
It returns random boolean.
Tekido.yes?
Tekido.yes?(80)
.percent
It retuens random percentage (0..100). It behaves the same as rand(0..100)
.
.percent_as
It returns random percentage. Can select return value type.
Tekido.percent_as(:integer)
Tekido.percent_as(:float)
Tekido.percent_as(:mo5)
Tekido.percent_as(:deca)
Tekido.percent_as(:mo10)
.integer
It always returns random value as integer.
Tekido.integer
Tekido.integer(9999)
Tekido.integer(1..1234)
.float
It always returns random value as float. The different with rand
is return value type only.
Tekido.float
Tekido.float(777.77)
Tekido.float(1..1234)
Tekido.float(1.1..1234.5)
.list
It returns Array instance that is filled by given sample values and ratio.
Tekido.list(10000, %w(one two three four))
Tekido.list(10000, 'one' => 11.1, 'two' => 22.2, 'three' => 33.3, 'four' => 33.4)
Tekido.list(10000, 'one' => 10, 'two' => 20, 'three' => 30)
.date
It returns random Date instance.
Tekido.date
Tekido.date(2010)
Tekido.date(1999..2007)
Tekido.date(Date.new(1999, 2, 21)..Date.new(2003, 10, 7))
.birthday
It returns random birthday as Date instance.
Tekido.birthday
Tekido.birthday(28)
Tekido.birthday(21..25)
.string
It returns random String instance.
Tekido.string
Tekido.string(size: 10, components: [:upper, :number])
Tekido.string(size: 8..16, chars: %w(1 3 5 7 9 x y z))
email
It returns random email address.
Tekido.email
Tekido.email('foobar.com')
Tekido.email("foo.bar@baz.com")
Tekido.email('test@foo.com', 'bar.com', '@baz.com')
Supported ruby versions
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request