Class: Eco::CLI::Config::Filters
- Inherits:
-
Object
- Object
- Eco::CLI::Config::Filters
- Includes:
- Help
- Defined in:
- lib/eco/cli/config/filters.rb,
lib/eco/cli/config/filters/input_filters.rb,
lib/eco/cli/config/filters/people_filters.rb
Direct Known Subclasses
Defined Under Namespace
Classes: InputFilters, PeopleFilters
Instance Attribute Summary collapse
-
#core_config ⇒ Object
readonly
Returns the value of attribute core_config.
Instance Method Summary collapse
- #add(option, desc = nil) ⇒ Object
-
#help(msg = "The following are the available filters:") ⇒ String
Summary of the filters.
-
#initialize(core_config:) ⇒ Filters
constructor
A new instance of Filters.
- #process(io:) ⇒ Object
Constructor Details
#initialize(core_config:) ⇒ Filters
Returns a new instance of Filters.
8 9 10 11 12 |
# File 'lib/eco/cli/config/filters.rb', line 8 def initialize(core_config:) @core_config = core_config @filters = {} @description = {} end |
Instance Attribute Details
#core_config ⇒ Object (readonly)
Returns the value of attribute core_config.
6 7 8 |
# File 'lib/eco/cli/config/filters.rb', line 6 def core_config @core_config end |
Instance Method Details
#add(option, desc = nil) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/eco/cli/config/filters.rb', line 27 def add(option, desc = nil) raise "Missing block to define the filters builder" unless block_given? callback = Proc.new [option].flatten.compact.each do |opt| @filters[opt] = callback @description[opt] = desc end self end |
#help(msg = "The following are the available filters:") ⇒ String
Returns summary of the filters.
15 16 17 18 19 20 21 22 23 |
# File 'lib/eco/cli/config/filters.rb', line 15 def help(msg = "The following are the available filters:") [msg].yield_self do |lines| max_len = keys_max_len(@filters.keys) @filters.keys.sort.each do |key| lines << help_line(key, @description[key], max_len) end lines end.join("\n") end |
#process(io:) ⇒ Object
37 38 39 |
# File 'lib/eco/cli/config/filters.rb', line 37 def process(io:) raise "You need to override this method in child classes" end |