Module: Logue::Colorable
- Includes:
- Dynamic
- Included in:
- Logger
- Defined in:
- lib/logue/colorable.rb
Instance Method Summary
collapse
Methods included from Dynamic
#add_class_method, #add_color_method
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &blk) ⇒ Object
20
21
22
23
24
25
26
27
28
|
# File 'lib/logue/colorable.rb', line 20
def method_missing meth, *args, &blk
code = valid_colors[meth]
if code
add_color_method meth.to_s, code + 30
send meth, *args, &blk
else
super
end
end
|
Instance Method Details
#methods(all = true) ⇒ Object
34
35
36
|
# File 'lib/logue/colorable.rb', line 34
def methods all = true
super + valid_colors.keys
end
|
#respond_to?(meth) ⇒ Boolean
30
31
32
|
# File 'lib/logue/colorable.rb', line 30
def respond_to? meth
valid_colors.include?(meth) || super
end
|
#valid_colors ⇒ Object
38
39
40
41
|
# File 'lib/logue/colorable.rb', line 38
def valid_colors
Rainbow::Color::Named::NAMES
end
|