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(&blk) ⇒ 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.
28 29 30 31 32 |
# File 'lib/codeless_code/commands/filter_fables.rb', line 28 def initialize(catalog, , io: nil) @catalog = catalog @options = @io = io end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
24 25 26 |
# File 'lib/codeless_code/commands/filter_fables.rb', line 24 def @options end |
Instance Method Details
#call(&blk) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/codeless_code/commands/filter_fables.rb', line 34 def call(&blk) fables = (&blk) case fables.size when 0 warn 'None found.' when 1 show(fables.first) else list(fables) end end |