class ErbTagsRemover

Remove tags from erb file and output only an array of pure ruby code

Public Instance Methods

remove_erb_tags(text) click to toggle source
# File lib/ErbFileAnalyser/Erb_tags_remover.rb, line 5
def remove_erb_tags(text)
  all_tagged_chunks = text.scan(/(?<=\<%)(.*?)(?=\%>)/)
  all_tagged_chunks.each do |tagged_chunks|
    tagged_chunks.each do |tagged_chunk|
      if tagged_chunk[0] == '='
       tagged_chunk.slice!(0)
      end
      if tagged_chunk[-1] == '-'
        tagged_chunk.slice!(-1)
      end
        if tagged_chunk[0] == '#'
        tagged_chunks - [tagged_chunk]
      end
    end
  end
  all_tagged_chunks.join("\n")
end