class Milkode::PlangDetector
Constants
- LANGUAGES
- UNKNOWN
- UNKNOWN_LANGUAGE
Public Class Methods
new(filename)
click to toggle source
# File lib/milkode/common/plang_detector.rb, line 70 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
Public Instance Methods
filenames()
click to toggle source
# File lib/milkode/common/plang_detector.rb, line 116 def filenames @lang[:filenames] end
filepatterns()
click to toggle source
# File lib/milkode/common/plang_detector.rb, line 120 def filepatterns @lang[:filepatterns] end
name()
click to toggle source
# File lib/milkode/common/plang_detector.rb, line 108 def name @lang[:name] end
suffixs()
click to toggle source
# File lib/milkode/common/plang_detector.rb, line 112 def suffixs @lang[:suffixs] end
unknown?()
click to toggle source
# File lib/milkode/common/plang_detector.rb, line 124 def unknown? name == UNKNOWN end