Class: Opal::Rewriter
- Inherits:
-
Object
- Object
- Opal::Rewriter
- Defined in:
- opal/lib/opal/rewriter.rb
Class Method Summary collapse
- .delete(rewriter) ⇒ Object
- .disable ⇒ Object
- .disabled? ⇒ Boolean
- .list ⇒ Object
- .use(rewriter) ⇒ Object
Instance Method Summary collapse
-
#initialize(sexp) ⇒ Rewriter
constructor
A new instance of Rewriter.
- #process ⇒ Object
Constructor Details
#initialize(sexp) ⇒ Rewriter
Returns a new instance of Rewriter.
60 61 62 |
# File 'opal/lib/opal/rewriter.rb', line 60 def initialize(sexp) @sexp = sexp end |
Class Method Details
.delete(rewriter) ⇒ Object
29 30 31 |
# File 'opal/lib/opal/rewriter.rb', line 29 def delete(rewriter) list.delete(rewriter) end |
.disable ⇒ Object
33 34 35 36 37 38 |
# File 'opal/lib/opal/rewriter.rb', line 33 def disable @disabled = true yield ensure @disabled = false end |
.disabled? ⇒ Boolean
40 41 42 |
# File 'opal/lib/opal/rewriter.rb', line 40 def disabled? @disabled if defined?(@disabled) end |
.list ⇒ Object
21 22 23 |
# File 'opal/lib/opal/rewriter.rb', line 21 def list @list ||= [] end |
.use(rewriter) ⇒ Object
25 26 27 |
# File 'opal/lib/opal/rewriter.rb', line 25 def use(rewriter) list << rewriter end |
Instance Method Details
#process ⇒ Object
64 65 66 67 68 69 70 71 72 73 |
# File 'opal/lib/opal/rewriter.rb', line 64 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 |