Module: CssColorContrast::Cli
- Defined in:
- lib/css_color_contrast/cli.rb
Constant Summary collapse
- BANNER =
<<~BANNER To calculate the contrast ratio between 2 colors, enter the following command: > ratio: color1 color2 For the values of color1 and color2, hexadecimal notation, RGB/HSL/HWB functions and the extended color keywords are supported. To finish the program, enter 'exit'. BANNER
Class Method Summary collapse
Class Method Details
.print_banner ⇒ Object
19 20 21 |
# File 'lib/css_color_contrast/cli.rb', line 19 def self. $stdout.print BANNER end |
.read_commands ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/css_color_contrast/cli.rb', line 23 def self.read_commands env = {} while line = Readline.readline('> ', true) begin exit if line.chomp == 'exit' func = CommandInterpreter::Parser.parse!(line.chomp, env) $stdout.puts func.evaluate rescue => e puts e end end end |
.start ⇒ Object
37 38 39 40 |
# File 'lib/css_color_contrast/cli.rb', line 37 def self.start read_commands end |