class I18nLinter::Rules::MimeType

Public Instance Methods

check(tokens) click to toggle source
# File lib/i18n_linter/rules/mime_type.rb, line 8
def check(tokens)
  tokens[0] == :string_content && mime_type?(tokens)
end

Private Instance Methods

check_mime_types(tokens) click to toggle source
# File lib/i18n_linter/rules/mime_type.rb, line 21
def check_mime_types(tokens)
  string = tokens[1]
  MIME::Types.any? { |mime| string.include?(mime) }
end
mime_type?(tokens) click to toggle source
# File lib/i18n_linter/rules/mime_type.rb, line 14
def mime_type?(tokens)
  string_tokens = tokens[1]
  return false unless string_tokens

  string_tokens[0] == :@tstring_content && check_mime_types(string_tokens)
end