Class: MIME::Type
- Inherits:
-
Object
- Object
- MIME::Type
- Defined in:
- lib/distorted/checking_you_out.rb
Constant Summary collapse
- DISTORTED_METHOD_PREFIXES =
Provide a few variations on the base :distorted_method for mixed workflows where it isn’t feasible to overload a single method name and call :super. Jekyll, for example, renders its output markup upfront, collects all of the StaticFiles (or StaticStatic-includers, in our case), then calls their :write methods all at once after the rest of the site is built, and this precludes us from easily sharing method names between layers.
Hash[ :buffer => 'to'.freeze, :file => 'write'.freeze, :template => 'render'.freeze, ]
- SUB_TYPE_SEPARATORS =
/[-_+\.]/
Instance Method Summary collapse
-
#distorted_buffer_method ⇒ Object
Returns a Symbol name of the method that should return a String buffer containing the file in this Type.
-
#distorted_file_method ⇒ Object
Returns a Symbol name of the method that should write a file of this Type to a given path on a filesystem.
-
#distorted_template_method ⇒ Object
Returns a Symbol name of the method that should returns a context-appropriate Object for displaying the file as this Type.
-
#settings_paths ⇒ Object
Returns an Array[Array] of human-readable keys we can use for our YAML config, e.g.
Instance Method Details
#distorted_buffer_method ⇒ Object
Returns a Symbol name of the method that should return a String buffer containing the file in this Type.
59 |
# File 'lib/distorted/checking_you_out.rb', line 59 def distorted_buffer_method; "#{DISTORTED_METHOD_PREFIXES[:buffer]}_#{distorted_method_suffix}".to_sym; end |
#distorted_file_method ⇒ Object
Returns a Symbol name of the method that should write a file of this Type to a given path on a filesystem.
62 |
# File 'lib/distorted/checking_you_out.rb', line 62 def distorted_file_method; "#{DISTORTED_METHOD_PREFIXES[:file]}_#{distorted_method_suffix}".to_sym; end |
#distorted_template_method ⇒ Object
Returns a Symbol name of the method that should returns a context-appropriate Object for displaying the file as this Type. Might be e.g. a String buffer containing Rendered Liquid in Jekylland, or a Type-appropriate frame in some GUI toolkit in DD-Booth.
68 |
# File 'lib/distorted/checking_you_out.rb', line 68 def distorted_template_method; "#{DISTORTED_METHOD_PREFIXES[:template]}_#{distorted_method_suffix}".to_sym; end |
#settings_paths ⇒ Object
Returns an Array[Array] of human-readable keys we can use for our YAML config, e.g. :media_type ‘image’ & :sub_type ‘svg+xml’ would be split to [‘image’, ‘svg’]. ‘nil` `:sub_type`s will just be compacted out. Every non-nil :media_type will also request a key path [media_type, ’*‘] to allow for similar-type defaults, e.g. every image type outputting a fallback.
75 |
# File 'lib/distorted/checking_you_out.rb', line 75 def settings_paths; [[self.media_type, '*'.freeze], [self.media_type, self.sub_type&.split('+'.freeze)&.first].compact]; end |