Class: Squib::LayoutParser Private

Inherits:
Object
  • Object
show all
Defined in:
lib/squib/layout_parser.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Internal class for handling layouts

Instance Method Summary collapse

Constructor Details

#initialize(dpi = 300) ⇒ LayoutParser

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 a new instance of LayoutParser



8
9
10
# File 'lib/squib/layout_parser.rb', line 8

def initialize(dpi = 300)
  @dpi = dpi
end

Instance Method Details

#load_layout(files, initial = {}) ⇒ Object

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.

Load the layout file(s), if exists



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/squib/layout_parser.rb', line 14

def load_layout(files, initial = {})
  layout = initial
  Squib::logger.info { "  using layout(s): #{files}" }
  Array(files).each do |file|
    thefile = file
    thefile = builtin(file) unless File.exists?(file)
    if File.exists? thefile
      # note: YAML.load_file returns false on empty file
      yml = layout.merge(YAML.load_file(thefile) || {})
      yml.each do |key, value|
        layout[key] = recurse_extends(yml, key, {})
      end
    else
      Squib::logger.error { "Layout file not found: #{file}. Skipping..." }
    end
  end
  return layout
end