class GroovyOneliner::Converter

Public Class Methods

new(content) click to toggle source
# File lib/groovy_oneliner/converter.rb, line 6
def initialize(content)
  @content = content
end

Public Instance Methods

compute() click to toggle source
# 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