Module: Dsu::Support::ColorThemable
- Included in:
- BaseCLI, CommandServices::AddEntryService, Models::ColorTheme, Presenters::BasePresenter, Dsu::Services::EntryGroup::EditorService, Views::BaseListView, Views::ColorTheme::Index, Views::ColorTheme::Show, Views::Configuration::Show, Views::EntryGroup::Shared::NoEntriesToDisplay, Views::EntryGroup::Show, Views::Export, Views::Import, Views::Project::Create, Views::Project::Delete, Views::Project::Rename, Views::Project::Use, Views::Shared::Message
- Defined in:
- lib/dsu/support/color_themable.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.apply_theme(input, theme_color:) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/dsu/support/color_themable.rb', line 19 def apply_theme(input, theme_color:) if input.is_a?(Array) return input.map do |string| colorize_string(string, theme_color: theme_color) end.join("\n") end colorize_string(input, theme_color: theme_color) end |
Instance Method Details
#prompt_with_options(prompt:, options:) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/dsu/support/color_themable.rb', line 8 def (prompt:, options:) # HACK: This module needs to be refactored to be more generic. target_color_theme = defined?(color_theme) ? color_theme : self = "[#{options.join(',')}]" "#{apply_theme(prompt, theme_color: target_color_theme.prompt)} " \ "#{apply_theme(options, theme_color: target_color_theme.prompt_options)}" \ "#{apply_theme('>', theme_color: target_color_theme.prompt)}" end |