Class: Arrolio::LayoutSpec
- Inherits:
-
Object
- Object
- Arrolio::LayoutSpec
- Defined in:
- lib/arrolio/layout_spec.rb,
lib/arrolio/layout_spec/flow.rb,
lib/arrolio/layout_spec/loader.rb,
lib/arrolio/layout_spec/region.rb,
lib/arrolio/layout_spec/scale_length.rb,
lib/arrolio/layout_spec/page_template.rb,
lib/arrolio/layout_spec/page_template_selector.rb
Defined Under Namespace
Modules: Loader Classes: Flow, PageTemplate, PageTemplateSelector, Region, ScaleLength
Instance Attribute Summary collapse
-
#cover_logo_config ⇒ Object
readonly
Returns the value of attribute cover_logo_config.
-
#default_page_template ⇒ Object
readonly
Returns the value of attribute default_page_template.
-
#flows ⇒ Object
readonly
Returns the value of attribute flows.
-
#font_manifest_config ⇒ Object
readonly
Returns the value of attribute font_manifest_config.
-
#font_paths ⇒ Object
readonly
Returns the value of attribute font_paths.
-
#header_footer_config ⇒ Object
readonly
Returns the value of attribute header_footer_config.
-
#page_templates ⇒ Object
readonly
Returns the value of attribute page_templates.
-
#styles ⇒ Object
readonly
Returns the value of attribute styles.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #flow(name) ⇒ Object
- #hash ⇒ Object
-
#initialize(page_templates:, default_page_template:, styles:, flows: {}, font_paths: {}, header_footer: {}, cover_logo: {}, font_manifest: {}) ⇒ LayoutSpec
constructor
A new instance of LayoutSpec.
- #page_template(name = nil) ⇒ Object
- #resolve_style(name, fallback: nil) ⇒ Object
Constructor Details
#initialize(page_templates:, default_page_template:, styles:, flows: {}, font_paths: {}, header_footer: {}, cover_logo: {}, font_manifest: {}) ⇒ LayoutSpec
Returns a new instance of LayoutSpec.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/arrolio/layout_spec.rb', line 17 def initialize(page_templates:, default_page_template:, styles:, flows: {}, font_paths: {}, header_footer: {}, cover_logo: {}, font_manifest: {}) @font_paths = font_paths.transform_keys(&:to_s).freeze @page_templates = page_templates.transform_keys(&:to_sym).freeze @default_page_template = default_page_template.to_sym @styles = styles @flows = flows.transform_keys(&:to_sym).freeze @header_footer_config = ( || {}).freeze @cover_logo_config = (cover_logo || {}).freeze @font_manifest_config = (font_manifest || {}).freeze validate! freeze end |
Instance Attribute Details
#cover_logo_config ⇒ Object (readonly)
Returns the value of attribute cover_logo_config.
13 14 15 |
# File 'lib/arrolio/layout_spec.rb', line 13 def cover_logo_config @cover_logo_config end |
#default_page_template ⇒ Object (readonly)
Returns the value of attribute default_page_template.
13 14 15 |
# File 'lib/arrolio/layout_spec.rb', line 13 def default_page_template @default_page_template end |
#flows ⇒ Object (readonly)
Returns the value of attribute flows.
13 14 15 |
# File 'lib/arrolio/layout_spec.rb', line 13 def flows @flows end |
#font_manifest_config ⇒ Object (readonly)
Returns the value of attribute font_manifest_config.
13 14 15 |
# File 'lib/arrolio/layout_spec.rb', line 13 def font_manifest_config @font_manifest_config end |
#font_paths ⇒ Object (readonly)
Returns the value of attribute font_paths.
13 14 15 |
# File 'lib/arrolio/layout_spec.rb', line 13 def font_paths @font_paths end |
#header_footer_config ⇒ Object (readonly)
Returns the value of attribute header_footer_config.
13 14 15 |
# File 'lib/arrolio/layout_spec.rb', line 13 def @header_footer_config end |
#page_templates ⇒ Object (readonly)
Returns the value of attribute page_templates.
13 14 15 |
# File 'lib/arrolio/layout_spec.rb', line 13 def page_templates @page_templates end |
#styles ⇒ Object (readonly)
Returns the value of attribute styles.
13 14 15 |
# File 'lib/arrolio/layout_spec.rb', line 13 def styles @styles end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/arrolio/layout_spec.rb', line 48 def ==(other) other.is_a?(self.class) && page_templates == other.page_templates && default_page_template == other.default_page_template && styles == other.styles && flows == other.flows && == other. && cover_logo_config == other.cover_logo_config && font_manifest_config == other.font_manifest_config end |
#flow(name) ⇒ Object
44 45 46 |
# File 'lib/arrolio/layout_spec.rb', line 44 def flow(name) @flows[name.to_sym] end |
#hash ⇒ Object
61 62 63 64 |
# File 'lib/arrolio/layout_spec.rb', line 61 def hash [self.class, page_templates, default_page_template, styles, flows, , cover_logo_config, font_manifest_config].hash end |
#page_template(name = nil) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/arrolio/layout_spec.rb', line 32 def page_template(name = nil) key = (name || @default_page_template).to_sym @page_templates[key] || (raise LayoutSpecError, "Unknown page template #{key.inspect}; have: #{@page_templates.keys.inspect}", spec_field: :page_template) end |
#resolve_style(name, fallback: nil) ⇒ Object
40 41 42 |
# File 'lib/arrolio/layout_spec.rb', line 40 def resolve_style(name, fallback: nil) @styles.resolve(name, fallback: fallback || Style::Definition.new) end |