Class: CodelessCode::Filters::Translator

Inherits:
Object
  • Object
show all
Defined in:
lib/codeless_code/filters/translator.rb

Overview

Matches fables translated by the person with the given name.

Instance Method Summary collapse

Constructor Details

#initialize(exact: nil, casecmp: nil) ⇒ Translator

Returns a new instance of Translator


22
23
24
25
# File 'lib/codeless_code/filters/translator.rb', line 22

def initialize(exact: nil, casecmp: nil)
  @exact = exact
  @casecmp = casecmp
end

Instance Method Details

#call(fable) ⇒ Object


31
32
33
34
35
36
# File 'lib/codeless_code/filters/translator.rb', line 31

def call(fable)
  trans = fable.translator
  return false unless @exact.nil? || @exact == trans

  @casecmp.nil? || @casecmp.casecmp?(trans)
end

#enabled?Boolean

Returns:

  • (Boolean)

27
28
29
# File 'lib/codeless_code/filters/translator.rb', line 27

def enabled?
  @exact || @casecmp
end