Module: StringUtility

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

Class Method Summary collapse

Class Method Details

.random_color_sixString

Gets a random six-digit hexadecimal web color string.

Returns:

  • (String)

    See #random_color_three



55
56
57
# File 'lib/utils.rb', line 55

def self.random_color_six
  random_color(6)
end

.random_color_threeString

Gets a random three-digit hexadecimal web color string.

Returns:

  • (String)

    A random hexadecimal.



49
50
51
# File 'lib/utils.rb', line 49

def self.random_color_three
  random_color(3)
end

.random_line(path) ⇒ String

Gets a random line in a file. This will include newlines and similar characters, so you may want to chomp the result.

Parameters:

  • path (String)

    The path to the file.

Returns:

  • (String)

    A random line in the file.



42
43
44
45
# File 'lib/utils.rb', line 42

def self.random_line(path)
  lines = File.readlines(path)
  lines[rand(lines.count)]
end