Top Level Namespace
Defined Under Namespace
Modules: Enumerable, FeedImport, Plug, Rbkb, Zlib Classes: Array, Float, Numeric, Object, String, Symbol
Instance Method Summary collapse
-
#random_alphanum(size = 8) ⇒ Object
Generates a random alphanumeric string of ‘size’ bytes (8 by default).
-
#random_string(size = 8) ⇒ Object
Generates a random string of ‘size’ bytes (8 by default).
-
#with(x) {|x| ... } ⇒ Object
Simple syntactic sugar to pass any object to a block.
Instance Method Details
#random_alphanum(size = 8) ⇒ Object
Generates a random alphanumeric string of ‘size’ bytes (8 by default)
14 15 16 17 |
# File 'lib/rbkb/extends.rb', line 14 def random_alphanum(size = 8) chars = ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a (1..size).collect{|a| chars[rand(chars.size)]}.join end |
#random_string(size = 8) ⇒ Object
Generates a random string of ‘size’ bytes (8 by default)
20 21 22 23 |
# File 'lib/rbkb/extends.rb', line 20 def random_string(size = 8) chars = (0..255).map {|c| c.chr } (1..size).collect {|a| chars[rand(chars.size)]} end |
#with(x) {|x| ... } ⇒ Object
Simple syntactic sugar to pass any object to a block
26 27 28 |
# File 'lib/rbkb/extends.rb', line 26 def with(x) yield x if block_given?; x end |