Module: Lexdrill::Color
- Defined in:
- lib/lexdrill/color.rb
Overview
Global "how to color a shown word" setting: "default" colors by show count (see Lexdrill::Colorizer's blue -> red gradient); "random" picks a vivid random color every time instead. An absent file (or any unrecognized value) means "default".
Constant Summary collapse
- PATH =
Lexdrill::Config.path("color")
- RANDOM =
"random"- DEFAULT =
"default"- VALID =
[RANDOM, DEFAULT].freeze
Class Method Summary collapse
Class Method Details
.current ⇒ Object
17 18 19 20 21 22 |
# File 'lib/lexdrill/color.rb', line 17 def self.current return DEFAULT unless File.exist?(PATH) value = File.read(PATH).strip VALID.include?(value) ? value : DEFAULT end |
.random? ⇒ Boolean
24 25 26 |
# File 'lib/lexdrill/color.rb', line 24 def self.random? current == RANDOM end |
.set(mode) ⇒ Object
13 14 15 |
# File 'lib/lexdrill/color.rb', line 13 def self.set(mode) File.write(PATH, mode) end |