module HighLine::BuiltinStyles::ClassMethods
BuiltinStyles
class methods to be extended.
Constants
- RGB_COLOR_PATTERN
-
Regexp to match against RGB style constant names.
Public Instance Methods
Source
# File lib/highline/builtin_styles.rb, line 103 def const_missing(name) raise NameError, "Bad color or uninitialized constant #{name}" unless name.to_s =~ RGB_COLOR_PATTERN on = Regexp.last_match(1) suffix = Regexp.last_match(4) code_name = if suffix Regexp.last_match(1).to_s + Regexp.last_match(2) + Regexp.last_match(3) else name.to_s end style_name = code_name + "_STYLE" style = Style.rgb(Regexp.last_match(3)) style = style.on if on const_set(style_name, style) const_set(code_name, style.code) suffix ? style : style.code end
const_missing
callback for automatically respond to builtin constants (without explicitly defining them) @param name [Symbol] missing constant name