Module: Ruby2JS::Filter

Included in:
Processor
Defined in:
lib/ruby2js.rb,
lib/ruby2js/filter.rb,
lib/ruby2js/filter/cjs.rb,
lib/ruby2js/filter/esm.rb,
lib/ruby2js/filter/jsx.rb,
lib/ruby2js/filter/vue.rb,
lib/ruby2js/filter/node.rb,
lib/ruby2js/filter/react.rb,
lib/ruby2js/filter/jquery.rb,
lib/ruby2js/filter/return.rb,
lib/ruby2js/filter/require.rb,
lib/ruby2js/filter/matchAll.rb,
lib/ruby2js/filter/nokogiri.rb,
lib/ruby2js/filter/stimulus.rb,
lib/ruby2js/filter/camelCase.rb,
lib/ruby2js/filter/functions.rb,
lib/ruby2js/filter/underscore.rb,
lib/ruby2js/filter/securerandom.rb,
lib/ruby2js/filter/active_functions.rb,
lib/ruby2js/filter/minitest-jasmine.rb,
lib/ruby2js/filter/tagged_templates.rb

Defined Under Namespace

Modules: ActiveFunctions, CJS, CamelCase, ESM, Functions, JQuery, JSX, MatchAll, MiniTestJasmine, Node, Nokogiri, React, Require, Return, SEXP, SecureRandom, Stimulus, TaggedTemplates, Underscore, Vue Classes: Processor

Constant Summary collapse

DEFAULTS =
[]
@@included =

module level defaults

nil
@@excluded =
[]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exclude(*methods) ⇒ Object

indicate that the specified methods are not to be processed



25
26
27
28
29
30
31
# File 'lib/ruby2js/filter.rb', line 25

def self.exclude(*methods)
  if @@included
    @@included -= methods.flatten
  else
    @@excluded += methods.flatten
  end
end

.excluded_methodsObject



20
21
22
# File 'lib/ruby2js/filter.rb', line 20

def self.excluded_methods
  @@excluded&.dup
end

.include(*methods) ⇒ Object

indicate that the specified methods are to be processed



45
46
47
48
49
50
51
# File 'lib/ruby2js/filter.rb', line 45

def self.include(*methods)
  if @@included
    @@included += methods.flatten
  else
    @@excluded -= methods.flatten
  end
end

.include_allObject

indicate that all methods are to be processed



34
35
36
37
# File 'lib/ruby2js/filter.rb', line 34

def self.include_all
  @@included = nil
  @@excluded = []
end

.include_only(*methods) ⇒ Object

indicate that only the specified methods are to be processed



40
41
42
# File 'lib/ruby2js/filter.rb', line 40

def self.include_only(*methods)
  @@included = methods.flatten
end

.included_methodsObject



16
17
18
# File 'lib/ruby2js/filter.rb', line 16

def self.included_methods
  @@included&.dup
end

Instance Method Details

#exclude(*methods) ⇒ Object

indicate that the specified methods are not to be processed



88
89
90
91
92
93
94
# File 'lib/ruby2js/filter.rb', line 88

def exclude(*methods)
  if @included
    @included -= methods.flatten
  else
    @excluded += methods.flatten
  end
end

#excluded?(method) ⇒ Boolean

determine if a method is NOT to be processed

Returns:

  • (Boolean)


58
59
60
61
62
63
64
65
# File 'lib/ruby2js/filter.rb', line 58

def excluded?(method)
  if @included
    not @included.include? method
  else
    return true if @exclude_methods.flatten.include? method
    @excluded&.include? method
  end
end

#include(*methods) ⇒ Object

indicate that the specified methods are to be processed



79
80
81
82
83
84
85
# File 'lib/ruby2js/filter.rb', line 79

def include(*methods)
  if @included
    @included += methods.flatten
  else
    @excluded -= methods.flatten
  end
end

#include_allObject

indicate that all methods are to be processed



68
69
70
71
# File 'lib/ruby2js/filter.rb', line 68

def include_all
  @included = nil
  @excluded = []
end

#include_only(*methods) ⇒ Object

indicate that only the specified methods are to be processed



74
75
76
# File 'lib/ruby2js/filter.rb', line 74

def include_only(*methods)
  @included = methods.flatten
end