Class: CodelessCode::Filters::FromOptions

Inherits:
Composite
  • Object
show all
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

Methods inherited from Composite

#call

Constructor Details

#initialize(opts) ⇒ FromOptions

Returns a new instance of FromOptions

Parameters:


28
29
30
31
# File 'lib/codeless_code/filters/from_options.rb', line 28

def initialize(opts)
  @opts = opts
  @filters = nil
end

Instance Method Details

#enabled?Boolean

Returns:

  • (Boolean)

37
38
39
# File 'lib/codeless_code/filters/from_options.rb', line 37

def enabled?
  @opts.key?(:lang) || non_defaults_enabled?
end

#filtersObject


41
42
43
44
45
46
47
48
49
50
51
# File 'lib/codeless_code/filters/from_options.rb', line 41

def filters
  @filters ||=
    string_filters +
    integer_filters +
    [
      filter(:Date, :date),
      new_filter(:Lang, exact: lang),
      number_filter,
      translator_filter
    ]
end

#langObject


33
34
35
# File 'lib/codeless_code/filters/from_options.rb', line 33

def lang
  @opts[:lang]&.to_sym || fallback_lang
end