Class: Parser

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

Defined Under Namespace

Classes: ScriptOptions

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



192
193
194
# File 'lib/parser.rb', line 192

def args
  @args
end

#optionsObject (readonly)

Returns the value of attribute options.



192
193
194
# File 'lib/parser.rb', line 192

def options
  @options
end

#parserObject (readonly)

Returns the value of attribute parser.



192
193
194
# File 'lib/parser.rb', line 192

def parser
  @parser
end

Instance Method Details

#build_defaultsObject



188
# File 'lib/parser.rb', line 188

def build_defaults; end

#generate_defaultsObject



190
# File 'lib/parser.rb', line 190

def generate_defaults; end

#parse(command, args) ⇒ Object

Return a structure describing the options.



156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/parser.rb', line 156

def parse(command, args)
  @options = ScriptOptions.new
  @args = OptionParser.new do |parser|
    @options.define_options(parser)
    parser.parse!(args)
    set_command_defaults(command)
  rescue OptionParser::InvalidOption, OptionParser::MissingArgument => e
    puts e
    puts
    puts parser
    exit
  end
  @options
end

#serve_defaultsObject



182
183
184
185
186
# File 'lib/parser.rb', line 182

def serve_defaults
  options.pdf = false
  options.html = true
  options.html_path = internal_tmp_dir.join('resume.html')
end

#set_command_defaults(command) ⇒ Object



171
172
173
174
175
176
177
178
179
180
# File 'lib/parser.rb', line 171

def set_command_defaults(command)
  case command
  when 'serve'
    serve_defaults
  when 'build'
    build_defaults
  when 'generate'
    generate_defaults
  end
end