Class: ColorcodeConvertRgb::CLI
- Inherits:
-
Thor
- Object
- Thor
- ColorcodeConvertRgb::CLI
- Defined in:
- lib/colorcode_convert_rgb/cli.rb
Instance Method Summary collapse
Instance Method Details
#to_ints(color) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/colorcode_convert_rgb/cli.rb', line 7 def to_ints(color) if color.match(/^[#][a-fA-F0-9]{6}$/) hex = color.delete("#") elsif color.match(/^[a-fA-F0-9]{6}$/) hex = color else return puts 'Please enter the correct code.(e.g. #ffffff or ffffff )' end r, g, b = hex[0..1], hex[2..3], hex[4..5] rgb = [r, g, b].map(&:hex) puts "RGB is #{rgb}." end |