class Squib::LayoutParser
Internal class for handling layouts @api private
Public Class Methods
new(dpi = 300, cell_px = 37.5)
click to toggle source
# File lib/squib/layout_parser.rb, line 10 def initialize(dpi = 300, cell_px = 37.5) @dpi = dpi @cell_px = cell_px end
Public Instance Methods
load_layout(files, initial = {})
click to toggle source
Load the layout file(s), if exists @api private
# File lib/squib/layout_parser.rb, line 17 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
Private Instance Methods
builtin(file)
click to toggle source
Determine the file path of the built-in layout file
# File lib/squib/layout_parser.rb, line 39 def builtin(file) "#{File.dirname(__FILE__)}/builtin/layouts/#{file}" end