Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/string2color.rb

Overview

Add on to string class

Instance Method Summary collapse

Instance Method Details

#to_colorObject



5
6
7
# File 'lib/string2color.rb', line 5

def to_color
  "RGB(#{val_1}, #{val_2}, #{val_3})"
end

#val_1Object



9
10
11
12
13
14
15
16
# File 'lib/string2color.rb', line 9

def val_1
  size
  if size <= 10
    size * 9
  elsif size > 10 && size <= 90
    size * 2
  end
end

#val_2Object



18
19
20
# File 'lib/string2color.rb', line 18

def val_2
  self[2].ord
end

#val_3Object



22
23
24
# File 'lib/string2color.rb', line 22

def val_3
  self[/./].ord
end