Class: Opal::Rewriter

Inherits:
Object
  • Object
show all
Defined in:
opal/lib/opal/rewriter.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sexp) ⇒ Rewriter

Returns a new instance of Rewriter



49
50
51
# File 'opal/lib/opal/rewriter.rb', line 49

def initialize(sexp)
  @sexp = sexp
end

Class Method Details

.delete(rewriter) ⇒ Object



23
24
25
# File 'opal/lib/opal/rewriter.rb', line 23

def delete(rewriter)
  list.delete(rewriter)
end

.disableObject



27
28
29
30
31
32
# File 'opal/lib/opal/rewriter.rb', line 27

def disable
  @disabled = true
  yield
ensure
  @disabled = false
end

.disabled?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'opal/lib/opal/rewriter.rb', line 34

def disabled?
  @disabled if defined?(@disabled)
end

.listObject



15
16
17
# File 'opal/lib/opal/rewriter.rb', line 15

def list
  @list ||= []
end

.use(rewriter) ⇒ Object



19
20
21
# File 'opal/lib/opal/rewriter.rb', line 19

def use(rewriter)
  list << rewriter
end

Instance Method Details

#processObject



53
54
55
56
57
58
59
60
61
62
# File 'opal/lib/opal/rewriter.rb', line 53

def process
  return @sexp if self.class.disabled?

  self.class.list.each do |rewriter_class|
    rewriter = rewriter_class.new
    @sexp = rewriter.process(@sexp)
  end

  @sexp
end