Class: CodelessCode::Filters::FromOptions
- Extended by:
- Forwardable
- Defined in:
- lib/codeless_code/filters/from_options.rb
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.
24 25 26 27 |
# File 'lib/codeless_code/filters/from_options.rb', line 24 def initialize(opts) @opts = opts @filters = nil end |
Instance Method Details
#enabled? ⇒ Boolean
33 34 35 |
# File 'lib/codeless_code/filters/from_options.rb', line 33 def enabled? @opts.key?(:lang) || non_defaults_enabled? end |
#filters ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/codeless_code/filters/from_options.rb', line 37 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
29 30 31 |
# File 'lib/codeless_code/filters/from_options.rb', line 29 def lang @opts[:lang]&.to_sym || fallback_lang end |