class JpStringsFinder::Finder

Attributes

file_path[R]
filetype[R]

Public Class Methods

new(file_path) click to toggle source
# File lib/jp_strings_finder/finder.rb, line 11
def initialize(file_path)
  @file_path = file_path
  @filetype = FiletypeDetector.new(file_path).filetype
end

Public Instance Methods

find() click to toggle source
# File lib/jp_strings_finder/finder.rb, line 16
def find
  File.open(file_path) do |f|
    finder = filetype_specific_finder.new(f.read)
    finder.find.select do |str|
      JapaneseDetector.contain_japanese?(str)
    end
  end
end

Private Instance Methods

filetype_specific_finder() click to toggle source
# File lib/jp_strings_finder/finder.rb, line 27
def filetype_specific_finder
  @filetype_specific_finder ||=
    case filetype
    when :ruby
      RubyFinder
    when :erb
      ERBFinder
    when :slim
      SlimFinder
    end
end