class CodeCaser::Converter
Public Class Methods
new(opts={})
click to toggle source
# File lib/code_caser/converters.rb, line 5 def initialize(opts={}) if opts[:ignore_after] @ignore_after = Regexp.new('(^.*?)(' + Regexp.escape(opts[:ignore_after]) + '.*)') end end
Public Instance Methods
chop(line)
click to toggle source
# File lib/code_caser/converters.rb, line 25 def chop(line) @ignore_after && (data = match_data(line)) ? data[1] : line end
convert_line(line, verbose=false)
click to toggle source
# File lib/code_caser/converters.rb, line 11 def convert_line(line, verbose=false) converted_line = if @ignore_after && (data = match_data(line)) convert_string(data[1]) + data[2] else convert_string(line) end if verbose && converted_line != line puts "\n " + line.strip puts " " + converted_line.strip.colorize(:green) end converted_line end
convert_string()
click to toggle source
# File lib/code_caser/converters.rb, line 29 def convert_string # concrete Converter implementations must supply this method raise NotImplementedError end
Private Instance Methods
match_data(line)
click to toggle source
# File lib/code_caser/converters.rb, line 35 def match_data(line) line.match(@ignore_after) end