Class: Parser
- Inherits:
-
Object
- Object
- Parser
- Defined in:
- lib/parser.rb
Defined Under Namespace
Classes: ScriptOptions
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
Instance Method Summary collapse
- #build_defaults ⇒ Object
- #generate_defaults ⇒ Object
-
#parse(command, args) ⇒ Object
Return a structure describing the options.
- #serve_defaults ⇒ Object
- #set_command_defaults(command) ⇒ Object
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
192 193 194 |
# File 'lib/parser.rb', line 192 def args @args end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
192 193 194 |
# File 'lib/parser.rb', line 192 def @options end |
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
192 193 194 |
# File 'lib/parser.rb', line 192 def parser @parser end |
Instance Method Details
#build_defaults ⇒ Object
188 |
# File 'lib/parser.rb', line 188 def build_defaults; end |
#generate_defaults ⇒ Object
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.(parser) parser.parse!(args) set_command_defaults(command) rescue OptionParser::InvalidOption, OptionParser::MissingArgument => e puts e puts puts parser exit end @options end |
#serve_defaults ⇒ Object
182 183 184 185 186 |
# File 'lib/parser.rb', line 182 def serve_defaults .pdf = false .html = true .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 |