Class: CodelessCode::Commands::FilterFables
- Inherits:
-
Object
- Object
- CodelessCode::Commands::FilterFables
- Defined in:
- lib/codeless_code/commands/filter_fables.rb
Overview
Filters down a CodelessCode::Catalog of Fables with criteria specified via the CLI. The results will be listed line-by-line, unless only one fable is found. In that case, it will be printed out.
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(catalog, options, io: nil) ⇒ FilterFables
constructor
A new instance of FilterFables.
Constructor Details
#initialize(catalog, options, io: nil) ⇒ FilterFables
Returns a new instance of FilterFables.
26 27 28 29 30 |
# File 'lib/codeless_code/commands/filter_fables.rb', line 26 def initialize(catalog, , io: nil) @catalog = catalog = @io = io end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
22 23 24 |
# File 'lib/codeless_code/commands/filter_fables.rb', line 22 def end |
Instance Method Details
#call ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/codeless_code/commands/filter_fables.rb', line 32 def call filter = Filters::FromOptions.new() fables = @catalog.select(filter) fables = yield fables if block_given? fables = sort(fables) case fables.size when 0 warn 'None found.' when 1 show(fables.first) else list(fables) end end |