Class: Squib::LayoutParser Private
- Inherits:
-
Object
- Object
- Squib::LayoutParser
- Includes:
- Args::XYWHShorthands
- 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
Constant Summary
Constants included from Args::XYWHShorthands
Args::XYWHShorthands::DECK_DIV_REGEX, Args::XYWHShorthands::DECK_MINUS_REGEX, Args::XYWHShorthands::DECK_ONLY, Args::XYWHShorthands::DECK_PLUS_REGEX, Args::XYWHShorthands::MIDDLE_MINUS_REGEX, Args::XYWHShorthands::MIDDLE_ONLY, Args::XYWHShorthands::MIDDLE_PLUS_REGEX
Instance Method Summary collapse
-
#initialize(dpi = 300, cell_px = 37.5) ⇒ LayoutParser
constructor
private
A new instance of LayoutParser.
-
#load_layout(files, initial = {}) ⇒ Object
private
Load the layout file(s), if exists.
Methods included from Args::XYWHShorthands
Constructor Details
#initialize(dpi = 300, cell_px = 37.5) ⇒ 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.
10 11 12 13 |
# File 'lib/squib/layout_parser.rb', line 10 def initialize(dpi = 300, cell_px = 37.5) @dpi = dpi @cell_px = cell_px 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
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# 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 |