lib/tidgrep/cli.rb in tidtools-0.0.5 vs lib/tidgrep/cli.rb in tidtools-0.0.6
- old
+ new
@@ -29,11 +29,11 @@
@title_regexp = @title && Regexp.new(@title, @regexp_option)
@content_regexps = []
keywords.each do |keyword|
- @content_regexps << Regexp.new(self.kconv(keyword), @regexp_option)
+ @content_regexps << Regexp.new(kcode2utf(keyword), @regexp_option)
end
end
def validOption?
return false if !@file_name
@@ -45,23 +45,31 @@
return false if content_regexp !~ target
end
return true
end
- def kconv(str)
+ def kcode2utf(str)
if (@kcode != Kconv::UTF8)
- str.kconv(@kconv, Kconv::UTF8)
+ str.kconv(Kconv::UTF8, @kcode)
else
str
end
end
+ def utf2kcode(str)
+ if (@kcode != Kconv::UTF8)
+ str.kconv(@kcode, Kconv::UTF8)
+ else
+ str
+ end
+ end
+
def print(msg)
- @stdout.print self.kconv msg
+ @stdout.print utf2kcode(msg)
end
def puts(msg)
- @stdout.puts self.kconv msg
+ @stdout.puts utf2kcode(msg)
end
def match_line
tiddles = Tiddle.parse_sort_modified(@file_name)