Class: Squib::Conf Private
- Inherits:
-
Object
- Object
- Squib::Conf
- Defined in:
- lib/squib/conf.rb
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.
Constant Summary collapse
- DEFAULTS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ 'antialias' => 'best', 'backend' => 'memory', 'cell_px' => 37.5, 'count_format' => '%02d', 'custom_colors' => {}, 'dir' => '_output', 'hint' => :none, 'img_dir' => '.', 'img_missing' => :warn, 'progress_bars' => false, 'prefix' => 'card_', 'ldquote' => "\u201C", # UTF8 chars 'rdquote' => "\u201D", 'lsquote' => "\u2018", 'rsquote' => "\u2019", 'em_dash' => "\u2014", 'en_dash' => "\u2013", 'ellipsis' => "\u2026", 'smart_quotes' => true, 'text_hint' => 'off', 'warn_ellipsize' => true, 'warn_png_scale' => true, }
- ANTIALIAS_OPTS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Translate the hints to the methods.
{ nil => 'subpixel', 'best' => 'subpixel', 'good' => 'gray', 'fast' => 'gray', 'gray' => 'gray', 'subpixel' => 'subpixel' }
Class Method Summary collapse
-
.load(file) ⇒ Object
private
Load the configuration file, if exists, overriding hardcoded defaults.
Instance Method Summary collapse
- #antialias ⇒ Object private
- #backend ⇒ Object private
- #cell_px ⇒ Object private
- #count_format ⇒ Object private
- #custom_colors ⇒ Object private
- #dir ⇒ Object private
- #img_dir ⇒ Object private
- #img_missing ⇒ Object private
-
#initialize(config_hash = DEFAULTS) ⇒ Conf
constructor
private
A new instance of Conf.
- #prefix ⇒ Object private
- #progress_bars ⇒ Object private
- #text_hint ⇒ Object private
- #text_hint=(hint) ⇒ Object private
- #to_s ⇒ Object private
- #typographer ⇒ Object private
- #warn_ellipsize? ⇒ Boolean private
- #warn_png_scale? ⇒ Boolean private
Constructor Details
#initialize(config_hash = DEFAULTS) ⇒ Conf
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 Conf.
52 53 54 55 56 |
# File 'lib/squib/conf.rb', line 52 def initialize(config_hash = DEFAULTS) @config_hash = config_hash.merge USER_CONFIG # programmatic overrides yml @typographer = Args::Typographer.new(config_hash) normalize_antialias end |
Class Method Details
.load(file) ⇒ 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 configuration file, if exists, overriding hardcoded defaults
60 61 62 63 64 65 66 67 68 |
# File 'lib/squib/conf.rb', line 60 def self.load(file) yaml = {} if File.exist? file Squib::logger.info { " using config: #{file}" } yaml = YAML.load_file(file) || {} end warn_unrecognized(yaml) Conf.new(DEFAULTS.merge(yaml)) end |
Instance Method Details
#antialias ⇒ 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.
114 115 116 |
# File 'lib/squib/conf.rb', line 114 def antialias @config_hash['antialias'] end |
#backend ⇒ 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.
118 119 120 |
# File 'lib/squib/conf.rb', line 118 def backend @config_hash['backend'] end |
#cell_px ⇒ 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.
98 99 100 |
# File 'lib/squib/conf.rb', line 98 def cell_px @config_hash['cell_px'].to_f end |
#count_format ⇒ 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.
110 111 112 |
# File 'lib/squib/conf.rb', line 110 def count_format @config_hash['count_format'] end |
#custom_colors ⇒ 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.
122 123 124 |
# File 'lib/squib/conf.rb', line 122 def custom_colors @config_hash['custom_colors'] end |
#dir ⇒ 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.
102 103 104 |
# File 'lib/squib/conf.rb', line 102 def dir @config_hash['dir'] end |
#img_dir ⇒ 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.
74 75 76 |
# File 'lib/squib/conf.rb', line 74 def img_dir @config_hash['img_dir'] end |
#img_missing ⇒ 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.
78 79 80 |
# File 'lib/squib/conf.rb', line 78 def img_missing @config_hash['img_missing'].to_sym end |
#prefix ⇒ 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.
106 107 108 |
# File 'lib/squib/conf.rb', line 106 def prefix @config_hash['prefix'] end |
#progress_bars ⇒ 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.
90 91 92 |
# File 'lib/squib/conf.rb', line 90 def @config_hash['progress_bars'] end |
#text_hint ⇒ 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.
82 83 84 |
# File 'lib/squib/conf.rb', line 82 def text_hint @config_hash['text_hint'] end |
#text_hint=(hint) ⇒ 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.
86 87 88 |
# File 'lib/squib/conf.rb', line 86 def text_hint=(hint) @config_hash['text_hint'] = hint end |
#to_s ⇒ 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.
70 71 72 |
# File 'lib/squib/conf.rb', line 70 def to_s "Conf: #{@config_hash.to_s}" end |
#typographer ⇒ 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.
94 95 96 |
# File 'lib/squib/conf.rb', line 94 def typographer @typographer end |
#warn_ellipsize? ⇒ Boolean
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.
126 127 128 |
# File 'lib/squib/conf.rb', line 126 def warn_ellipsize? @config_hash['warn_ellipsize'] end |
#warn_png_scale? ⇒ Boolean
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.
130 131 132 |
# File 'lib/squib/conf.rb', line 130 def warn_png_scale? @config_hash['warn_png_scale'] end |