Module: Asciidoctor::Diagram::Extensions::FormatRegistry
- Defined in:
- lib/asciidoctor-diagram/extensions.rb
Overview
Provides the means for diagram processors to register supported output formats and image generation routines
Instance Method Summary collapse
-
#default_format ⇒ Symbol
private
Returns the default format.
-
#formats ⇒ Hash
private
Returns the registered formats.
-
#register_format(format, type) {|parent, source| ... } ⇒ Object
Registers a supported format.
Instance Method Details
#default_format ⇒ Symbol
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the default format
55 56 57 |
# File 'lib/asciidoctor-diagram/extensions.rb', line 55 def default_format @default_format end |
#formats ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the registered formats
47 48 49 |
# File 'lib/asciidoctor-diagram/extensions.rb', line 47 def formats @formats ||= {} end |
#register_format(format, type) {|parent, source| ... } ⇒ Object
Registers a supported format. The first registered format becomes the default format for the block processor.
Examples
register_format(:png, :image ) do |parent, source|
File.read(source.to_s)
end
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/asciidoctor-diagram/extensions.rb', line 30 def register_format(format, type, &block) raise "Unsupported output type: #{type}" unless type == :image || type == :literal unless @default_format @default_format = format end formats[format] = { :type => type, :generator => block } end |