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 hexidecimal web color string.

Returns:

  • (String)

    See #random_color_three



66
67
68
69
# File 'lib/utils.rb', line 66

def self.random_color_six
  string = random_color(0..5)
  "##{string}"
end

.random_color_threeString

Gets a random three-digit hexidecimal web color string.

Returns:

  • (String)

    A random hexidecimal.



59
60
61
62
# File 'lib/utils.rb', line 59

def self.random_color_three
  string = random_color(0..2)
  "##{string}"
end

.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)].chomp
end