Method: Milkode::PlangDetector#initialize
- Defined in:
- lib/milkode/common/plang_detector.rb
#initialize(filename) ⇒ PlangDetector
Returns a new instance of PlangDetector.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/milkode/common/plang_detector.rb', line 71 def initialize(filename) suffix = File.extname(filename) suffix = suffix[1..-1] filename = File.basename(filename) @lang = LANGUAGES.find {|v| is_found = false if v[:suffixs] is_found = v[:suffixs].include?(suffix) end if !is_found && v[:filenames] is_found = v[:filenames].include?(filename) end if !is_found && v[:filepatterns] v[:filepatterns].each do |pattern| if filename.match pattern is_found = true break end end end is_found } if @lang.nil? if suffix @lang = {:name => "." + suffix, :suffixs => [suffix]} else @lang = UNKNOWN_LANGUAGE end end end |