Top Level Namespace

Defined Under Namespace

Modules: Enumerable, FeedImport, Plug, Rbkb, Zlib Classes: Array, Float, Numeric, Object, String, Symbol

Instance Method Summary collapse

Instance Method Details

#random_string(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_string(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

#with(x) {|x| ... } ⇒ Object

Simple syntactic sugar to pass any object to a block

Yields:

  • (x)


21
22
23
# File 'lib/rbkb/extends.rb', line 21

def with(x)
  yield x if block_given?; x
end