Class: GroovyOneliner::Converter
- Inherits:
-
Object
- Object
- GroovyOneliner::Converter
- Defined in:
- lib/groovy_oneliner/converter.rb
Instance Method Summary collapse
- #compute ⇒ Object
-
#initialize(content) ⇒ Converter
constructor
A new instance of Converter.
Constructor Details
#initialize(content) ⇒ Converter
Returns a new instance of Converter.
6 7 8 |
# File 'lib/groovy_oneliner/converter.rb', line 6 def initialize(content) @content = content end |
Instance Method Details
#compute ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/groovy_oneliner/converter.rb', line 10 def compute @content .gsub(/\/\/.*$/, '') # remove all comments // .gsub("\n", '') # remove all line-breaks .gsub("\"", "'") # substitute all double-quote to single-quote .gsub(/^$/, '') # remove all empty lines .gsub(%r{\/\*(\*(?!\/)|[^*])*\*\/}, '') # remove all /* */ comments .gsub(/\s*;\s*/, ';') # remove all whitespace before and after ; .gsub(/\s*=\s*/, '=') # remove all whitespace before and after ; .strip end |