Module: StringUtility

Extended by:
StringUtility
Included in:
StringUtility
Defined in:
lib/utils.rb

Class Method Summary collapse

Class Method Details

.random_line(path) ⇒ String

Gets a random line in a file.

Parameters:

  • path (String)

    The path to the file.

Returns:

  • (String)

    A random line in the file.



52
53
54
55
# File 'lib/utils.rb', line 52

def self.random_line(path)
  read = File.readlines(path)
  read[rand(read.size)]
end