Module: RailsConsolePro::ColorHelper
- Extended by:
- ColorHelper
- Included in:
- AssociationNavigator, BasePrinter, ColorHelper, RailsConsolePro::Commands::BaseCommand, ErrorHandler, Paginator
- Defined in:
- lib/rails_console_pro/color_helper.rb
Overview
Color helper module with memoization for performance
Instance Method Summary collapse
-
#bold_color(method, text) ⇒ Object
Helper for bold colored text.
-
#color(method, text) ⇒ Object
Delegates color methods to pastel with memoization.
-
#method_missing(method_name, *args, &block) ⇒ Object
Chainable color methods.
-
#pastel ⇒ Object
Memoized pastel instance.
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
Chainable color methods
24 25 26 27 28 29 30 |
# File 'lib/rails_console_pro/color_helper.rb', line 24 def method_missing(method_name, *args, &block) if pastel.respond_to?(method_name) pastel.public_send(method_name, *args, &block) else super end end |
Instance Method Details
#bold_color(method, text) ⇒ Object
Helper for bold colored text
19 20 21 |
# File 'lib/rails_console_pro/color_helper.rb', line 19 def bold_color(method, text) pastel.bold.public_send(method, text) end |
#color(method, text) ⇒ Object
Delegates color methods to pastel with memoization
14 15 16 |
# File 'lib/rails_console_pro/color_helper.rb', line 14 def color(method, text) pastel.public_send(method, text) end |
#pastel ⇒ Object
Memoized pastel instance
9 10 11 |
# File 'lib/rails_console_pro/color_helper.rb', line 9 def pastel @pastel ||= PASTEL end |
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
32 33 34 |
# File 'lib/rails_console_pro/color_helper.rb', line 32 def respond_to_missing?(method_name, include_private = false) pastel.respond_to?(method_name, include_private) || super end |