Class: Sevgi::Graphics::Document::Proto
- Defined in:
- lib/sevgi/graphics/document.rb
Overview
Base document root element class.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Element
#attributes, #children, #contents, #name, #parent
Class Method Summary collapse
-
.attributes ⇒ Hash{Symbol => Object}
Returns effective inherited root attributes for this document class.
-
.preambles ⇒ Array<String>?
Returns inherited preamble lines for this document class.
-
.profile ⇒ Sevgi::Graphics::Document::Profile?
Returns the nearest immutable profile metadata in the class hierarchy.
Instance Method Summary collapse
-
#call(**options) ⇒ String
Renders this document after its optional pre-render checks.
Methods inherited from Element
element, #initialize, root, root?, valid?
Constructor Details
This class inherits a constructor from Sevgi::Graphics::Element
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Sevgi::Graphics::Element
Class Method Details
.attributes ⇒ Hash{Symbol => Object}
Returns effective inherited root attributes for this document class. Profile update suffixes are applied from the oldest configured ancestor to this class.
498 499 500 501 502 503 504 505 |
# File 'lib/sevgi/graphics/document.rb', line 498 def self.attributes return {} if self == Proto ArgumentError.("Document class has no configured profile: #{self}") unless profile return superclass.attributes unless instance_variable_defined?(:@profile) Attributes.new(superclass.attributes).tap { it.merge!(@profile.attributes) }.to_h end |
.preambles ⇒ Array<String>?
Returns inherited preamble lines for this document class.
510 511 512 513 514 515 516 517 |
# File 'lib/sevgi/graphics/document.rb', line 510 def self.preambles return if self == Proto ArgumentError.("Document class has no configured profile: #{self}") unless profile return superclass.preambles unless instance_variable_defined?(:@profile) @profile.preambles || superclass.preambles end |
.profile ⇒ Sevgi::Graphics::Document::Profile?
Returns the nearest immutable profile metadata in the class hierarchy.
468 469 470 471 472 |
# File 'lib/sevgi/graphics/document.rb', line 468 def self.profile return @profile if instance_variable_defined?(:@profile) superclass.profile if superclass.respond_to?(:profile) end |
Instance Method Details
#call(**options) ⇒ String
Renders this document after its optional pre-render checks.
487 488 489 490 491 492 |
# File 'lib/sevgi/graphics/document.rb', line 487 def call(**) checks = DEFAULTS.merge(.select { |key, _| DEFAULTS.key?(key) }) self.PreRender(**checks) if respond_to?(:PreRender) = .reject { |key, _| DEFAULTS.key?(key) } self.Render(**) end |