class FlatKit::Format

Public Class Methods

for(path) click to toggle source
# File lib/flat_kit/format.rb, line 13
def self.for(path)
  find_child(:handles?, path.to_s)
end
for_with_fallback(path:, fallback: "auto") click to toggle source
# File lib/flat_kit/format.rb, line 17
def self.for_with_fallback(path:, fallback: "auto")
  # test by path
  format = ::FlatKit::Format.for(path)
  return format unless format.nil?

  # now try the fallback
  format = ::FlatKit::Format.for(fallback)
  return format
end
for_with_fallback!(path:, fallback: "auto") click to toggle source
# File lib/flat_kit/format.rb, line 27
def self.for_with_fallback!(path:, fallback: "auto")
  format = for_with_fallback(path: path, fallback: fallback)
  raise ::FlatKit::Error::UnknownFormat, "Unable to figure out format for '#{path}' with fallback '#{fallback}'" if format.nil?

  return format
end
format_name() click to toggle source
# File lib/flat_kit/format.rb, line 5
def self.format_name
  raise NotImplementedError, "#{self.class} must implemente #{self.class}.format_name"
end

Public Instance Methods

format_name() click to toggle source
# File lib/flat_kit/format.rb, line 9
def format_name
  self.class.format_name
end