Class: FlatKit::Format
Overview
Internal: The base class of all data file format classes
Class Method Summary
collapse
Instance Method Summary
collapse
children, find_child, find_children, inherited
Class Method Details
.for(path) ⇒ Object
17
18
19
|
# File 'lib/flat_kit/format.rb', line 17
def self.for(path)
find_child(:handles?, path.to_s)
end
|
.for_with_fallback(path:, fallback: "auto") ⇒ Object
21
22
23
24
25
26
27
28
|
# File 'lib/flat_kit/format.rb', line 21
def self.for_with_fallback(path:, fallback: "auto")
format = ::FlatKit::Format.for(path)
return format unless format.nil?
::FlatKit::Format.for(fallback)
end
|
.for_with_fallback!(path:, fallback: "auto") ⇒ Object
30
31
32
33
34
35
36
37
38
|
# File 'lib/flat_kit/format.rb', line 30
def self.for_with_fallback!(path:, fallback: "auto")
format = for_with_fallback(path: path, fallback: fallback)
if format.nil?
raise ::FlatKit::Error::UnknownFormat,
"Unable to figure out format for '#{path}' with fallback '#{fallback}'"
end
format
end
|
9
10
11
|
# File 'lib/flat_kit/format.rb', line 9
def self.format_name
raise NotImplementedError, "#{self.class} must implement #{self.class}.format_name"
end
|
Instance Method Details
13
14
15
|
# File 'lib/flat_kit/format.rb', line 13
def format_name
self.class.format_name
end
|