Module: Cloudkeeper::Entities::Convertables::Convertable
- Included in:
- ImageFile
- Defined in:
- lib/cloudkeeper/entities/convertables/convertable.rb
Constant Summary
collapse
- CONVERT_OUTPUT_FORMATS =
i(raw qcow2 vmdk).freeze
- FORMAT_REGEX =
/^to_(?<format>#{convert_output_formats.join('|')})$/
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *arguments, &block) ⇒ Object
22
23
24
25
26
27
|
# File 'lib/cloudkeeper/entities/convertables/convertable.rb', line 22
def method_missing(method, *arguments, &block)
result = method.to_s.match(FORMAT_REGEX)
return convert(result[:format]) if result && result[:format]
super
end
|
Class Method Details
9
10
11
|
# File 'lib/cloudkeeper/entities/convertables/convertable.rb', line 9
def self.convert_output_formats
CONVERT_OUTPUT_FORMATS
end
|
.included(base) ⇒ Object
15
16
17
18
19
20
|
# File 'lib/cloudkeeper/entities/convertables/convertable.rb', line 15
def self.included(base)
raise Cloudkeeper::Errors::Convertables::ConvertabilityError, "#{base.inspect} cannot become a convertable" \
unless base.method_defined?(:file) && base.method_defined?(:format)
super
end
|
Instance Method Details
#respond_to_missing?(method) ⇒ Boolean
29
30
31
|
# File 'lib/cloudkeeper/entities/convertables/convertable.rb', line 29
def respond_to_missing?(method, *)
method =~ FORMAT_REGEX || super
end
|