Class: CommentRipper::Javascript
- Inherits:
-
Object
- Object
- CommentRipper::Javascript
- Defined in:
- lib/javascript/comment_stripper.rb
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Javascript
constructor
A new instance of Javascript.
- #strip(tree_or_string) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Javascript
Returns a new instance of Javascript.
6 7 8 |
# File 'lib/javascript/comment_stripper.rb', line 6 def initialize(opts={}) # nothing here yet end |
Instance Method Details
#strip(tree_or_string) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/javascript/comment_stripper.rb', line 10 def strip(tree_or_string) if(tree_or_string.is_a? String) return strip(JavascriptLexer.new(tree_or_string).lex) end tree = tree_or_string tree.map do |t| case t when SingleLineComment, MultiLineComment "" else t.to_s end end.join end |