Class: LiterateRandomizer::Util
- Inherits:
-
Object
- Object
- LiterateRandomizer::Util
- Defined in:
- lib/literate_randomizer/util.rb
Overview
A few utility methods
Class Method Summary collapse
-
.capitalize(word) ⇒ Object
return word with the first letter capitalized.
-
.max(r) ⇒ Object
r can be an Integer of a Range.
-
.rand_count(r, randomizer = Random.new) ⇒ Object
r can be an Integer of a Range.
Class Method Details
.capitalize(word) ⇒ Object
return word with the first letter capitalized
20 21 22 |
# File 'lib/literate_randomizer/util.rb', line 20 def capitalize(word) word.chars.first.upcase+word[1..-1] end |
.max(r) ⇒ Object
r can be an Integer of a Range. If an intenger, return r, else, return a the maximum value in the range.
8 9 10 11 |
# File 'lib/literate_randomizer/util.rb', line 8 def max(r) return r if r.kind_of? Integer r.max end |
.rand_count(r, randomizer = Random.new) ⇒ Object
r can be an Integer of a Range. If an intenger, return r, else, return a random number within the range.
14 15 16 17 |
# File 'lib/literate_randomizer/util.rb', line 14 def rand_count(r,randomizer=Random.new) return r if r.kind_of? Integer randomizer.rand(r.max-r.min)+r.min end |