Class: Slideshow::Opts
- Inherits:
-
Object
- Object
- Slideshow::Opts
- Defined in:
- lib/slideshow/opts.rb
Overview
todo: split (command line) options and headers? e.g. share (command line) options between slide shows (but not headers?)
Constant Summary
- DEFAULTS =
{ :title => 'Untitled Slide Show', :footer => '', :subfooter => '', :gradient_theme => 'dark', :gradient_color1 => 'red', :gradient_color2 => 'black', :code_engine => 'sh', # SyntaxHighligher (sh) | ultraviolet (uv) | coderay (cr) :code_txmt => 'false', # Text Mate Hyperlink for Source? }
Instance Method Summary (collapse)
- - (Object) [](key)
- - (Object) code_engine
- - (Object) code_txmt
- - (Object) config_path
- - (Boolean) fetch?
- - (Object) fetch_uri
- - (Boolean) generate?
- - (Object) get(key, default)
- - (Object) gradient=(value)
- - (Object) gradient_color=(value)
- - (Object) gradient_colors=(value)
- - (Object) gradient_theme=(value)
- - (Boolean) has_includes?
- - (Object) includes
-
- (Opts) initialize
constructor
A new instance of Opts.
- - (Boolean) list?
- - (Object) manifest
- - (Object) output_path
- - (Object) put(key, value)
- - (Object) set_defaults
Constructor Details
- (Opts) initialize
A new instance of Opts
8 9 10 |
# File 'lib/slideshow/opts.rb', line 8 def initialize @hash = {} end |
Instance Method Details
- (Object) [](key)
39 40 41 42 43 44 45 46 47 |
# File 'lib/slideshow/opts.rb', line 39 def []( key ) value = @hash[ normalize_key( key ) ] if value.nil? puts "** Warning: header '#{key}' undefined" "- #{key} not found -" else value end end |
- (Object) code_engine
86 87 88 |
# File 'lib/slideshow/opts.rb', line 86 def code_engine get( 'code-engine', DEFAULTS[ :code_engine ] ) end |
- (Object) code_txmt
90 91 92 |
# File 'lib/slideshow/opts.rb', line 90 def code_txmt get( 'code-txmt', DEFAULTS[ :code_txmt ]) end |
- (Object) config_path
78 79 80 |
# File 'lib/slideshow/opts.rb', line 78 def config_path get( 'config_path', nil ) end |
- (Boolean) fetch?
57 58 59 |
# File 'lib/slideshow/opts.rb', line 57 def fetch? get( 'fetch_uri', nil ) != nil end |
- (Object) fetch_uri
61 62 63 |
# File 'lib/slideshow/opts.rb', line 61 def fetch_uri get( 'fetch_uri', '-fetch uri required-' ) end |
- (Boolean) generate?
49 50 51 |
# File 'lib/slideshow/opts.rb', line 49 def generate? get_boolean( 'generate', false ) end |
- (Object) get(key, default)
114 115 116 |
# File 'lib/slideshow/opts.rb', line 114 def get( key, default ) @hash.fetch( normalize_key(key), default ) end |
- (Object) gradient=(value)
23 24 25 |
# File 'lib/slideshow/opts.rb', line 23 def gradient=( value ) put_gradient( value, :theme, :color1, :color2 ) end |
- (Object) gradient_color=(value)
31 32 33 |
# File 'lib/slideshow/opts.rb', line 31 def gradient_color=( value ) put_gradient( value, :color1 ) end |
- (Object) gradient_colors=(value)
27 28 29 |
# File 'lib/slideshow/opts.rb', line 27 def gradient_colors=( value ) put_gradient( value, :color1, :color2 ) end |
- (Object) gradient_theme=(value)
35 36 37 |
# File 'lib/slideshow/opts.rb', line 35 def gradient_theme=( value ) put_gradient( value, :theme ) end |
- (Boolean) has_includes?
65 66 67 |
# File 'lib/slideshow/opts.rb', line 65 def has_includes? @hash[ :include ] end |
- (Object) includes
69 70 71 72 |
# File 'lib/slideshow/opts.rb', line 69 def includes # fix: use os-agnostic delimiter (use : for Mac/Unix?) has_includes? ? @hash[ :include ].split( ';' ) : [] end |
- (Boolean) list?
53 54 55 |
# File 'lib/slideshow/opts.rb', line 53 def list? get_boolean( 'list', false ) end |
- (Object) manifest
74 75 76 |
# File 'lib/slideshow/opts.rb', line 74 def manifest get( 'manifest', 's6.txt' ) end |
- (Object) output_path
82 83 84 |
# File 'lib/slideshow/opts.rb', line 82 def output_path get( 'output', '.' ) end |
- (Object) put(key, value)
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/slideshow/opts.rb', line 12 def put( key, value ) key = normalize_key( key ) setter = "#{key}=".to_sym if respond_to? setter send setter, value else @hash[ key ] = value end end |
- (Object) set_defaults
108 109 110 111 112 |
# File 'lib/slideshow/opts.rb', line 108 def set_defaults DEFAULTS.each_pair do | key, value | @hash[ key ] = value if @hash[ key ].nil? end end |