Class: Slideshow::Opts

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

Overview

todo: split (command line) options and headers? e.g. share (command line) options between slide shows (but not headers?)

Constant Summary collapse

DEFAULTS =
{
  :title             => 'Untitled Slide Show',
  :footer            => '',
  :subfooter         => '',
  :gradient_theme    => 'dark',
  :gradient_color1   => 'red',
  :gradient_color2   => 'black',
  :code_theme        => 'amy',
  :code_line_numbers => 'true'
}

Instance Method Summary collapse

Constructor Details

#initializeOpts

Returns a new instance of Opts.



37
38
39
# File 'lib/slideshow.rb', line 37

def initialize
  @hash = {}
end

Instance Method Details

#[](key) ⇒ Object



72
73
74
75
76
77
78
79
80
# File 'lib/slideshow.rb', line 72

def []( key )
  value = @hash[ normalize_key( key ) ]
  if value.nil?
    puts "** Warning: header '#{key}' undefined"
    "- #{key} not found -"
  else
    value 
  end
end

#code_line_numbers?Boolean

Returns:

  • (Boolean)


107
108
109
# File 'lib/slideshow.rb', line 107

def code_line_numbers?
  get_boolean( 'code-line-numbers', DEFAULTS[ :code_line_numbers ] )
end

#code_themeObject



103
104
105
# File 'lib/slideshow.rb', line 103

def code_theme
  get( 'code-theme', DEFAULTS[ :code_theme ] )
end

#code_theme=(value) ⇒ Object



52
53
54
# File 'lib/slideshow.rb', line 52

def code_theme=( value )
  @hash[ :code_theme ] = value.tr( '-', '_' )
end

#fullerscreen?Boolean

Returns:

  • (Boolean)


99
100
101
# File 'lib/slideshow.rb', line 99

def fullerscreen?
  get_boolean( 'fuller', false ) || get_boolean( 'fullerscreen', false )
end

#generate?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/slideshow.rb', line 82

def generate?
  get_boolean( 'generate', false )
end

#gradient=(value) ⇒ Object



56
57
58
# File 'lib/slideshow.rb', line 56

def gradient=( value )
  put_gradient( value, :theme, :color1, :color2 )
end

#gradient_color=(value) ⇒ Object



64
65
66
# File 'lib/slideshow.rb', line 64

def gradient_color=( value )
  put_gradient( value, :color1 )
end

#gradient_colors=(value) ⇒ Object



60
61
62
# File 'lib/slideshow.rb', line 60

def gradient_colors=( value )
  put_gradient( value, :color1, :color2 )
end

#gradient_theme=(value) ⇒ Object



68
69
70
# File 'lib/slideshow.rb', line 68

def gradient_theme=( value )
  put_gradient( value, :theme )
end

#has_includes?Boolean

Returns:

  • (Boolean)


86
87
88
# File 'lib/slideshow.rb', line 86

def has_includes?
  @hash[ :include ]
end

#includesObject



90
91
92
93
# File 'lib/slideshow.rb', line 90

def includes
  # fix: use os-agnostic delimiter (use : for Mac/Unix?)
  has_includes? ? @hash[ :include ].split( ';' ) : []
end

#manifestObject



111
112
113
# File 'lib/slideshow.rb', line 111

def manifest  
  get( 'manifest', 's6.txt' )
end

#output_pathObject



115
116
117
# File 'lib/slideshow.rb', line 115

def output_path
  get( 'output', '.' )
end

#put(key, value) ⇒ Object



41
42
43
44
45
46
47
48
49
50
# File 'lib/slideshow.rb', line 41

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

#s5?Boolean

Returns:

  • (Boolean)


95
96
97
# File 'lib/slideshow.rb', line 95

def s5?  
  get_boolean( 's5', false )
end

#set_defaultsObject



131
132
133
134
135
# File 'lib/slideshow.rb', line 131

def set_defaults      
  DEFAULTS.each_pair do | key, value |
    @hash[ key ] = value if @hash[ key ].nil?
  end
end