Class: FlatKit::Format
Class Method Summary
collapse
Instance Method Summary
collapse
children, find_child, inherited
Class Method Details
.for(path) ⇒ Object
13
14
15
|
# 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") ⇒ Object
17
18
19
20
21
22
23
24
25
|
# File 'lib/flat_kit/format.rb', line 17
def self.for_with_fallback(path:, fallback: "auto")
format = ::FlatKit::Format.for(path)
return format unless format.nil?
format = ::FlatKit::Format.for(fallback)
return format
end
|
.for_with_fallback!(path:, fallback: "auto") ⇒ Object
27
28
29
30
31
32
|
# 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
|
5
6
7
|
# File 'lib/flat_kit/format.rb', line 5
def self.format_name
raise NotImplementedError, "#{self.class} must implemente #{self.class}.format_name"
end
|
Instance Method Details
9
10
11
|
# File 'lib/flat_kit/format.rb', line 9
def format_name
self.class.format_name
end
|