Class: CodelessCode::Filters::FromOptions
- Extended by:
- Forwardable
- Defined in:
- lib/codeless_code/filters/from_options.rb
Overview
A Composite filter build from the arguments supplied via the CLI.
Instance Method Summary collapse
- #enabled? ⇒ Boolean
- #filters ⇒ Object
-
#initialize(opts) ⇒ FromOptions
constructor
A new instance of FromOptions.
- #lang ⇒ Object
Methods inherited from Composite
Constructor Details
#initialize(opts) ⇒ FromOptions
Returns a new instance of FromOptions.
26 27 28 29 |
# File 'lib/codeless_code/filters/from_options.rb', line 26 def initialize(opts) @opts = opts @filters = nil end |
Instance Method Details
#enabled? ⇒ Boolean
35 36 37 |
# File 'lib/codeless_code/filters/from_options.rb', line 35 def enabled? @opts.key?(:lang) || non_defaults_enabled? end |
#filters ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/codeless_code/filters/from_options.rb', line 39 def filters @filters ||= [ Filters::Lang.new(exact: lang), Filters::Translator.new(exact: @opts[:translator_exact], casecmp: @opts[:translator]), Filters::Credits.new(**str_args(:credits)), Filters::Name.new(**str_args(:name)), Filters::Series.new(**str_args(:series)), Filters::Tagline.new(**str_args(:tagline)), Filters::Title.new(**str_args(:title)), Filters::Geekiness.new(**int_args(:geekiness)), Filters::Number.new(**int_args(:number).tap do |n| n[:exact] ||= @opts.args.last&.to_i end), Filters::Date.new(**date_args), ] end |
#lang ⇒ Object
31 32 33 |
# File 'lib/codeless_code/filters/from_options.rb', line 31 def lang @opts[:lang]&.to_sym || fallback_lang end |