Class: Justy::Parser
- Inherits:
-
Object
- Object
- Justy::Parser
- Defined in:
- lib/justy/parser.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#options_parser ⇒ Object
readonly
Returns the value of attribute options_parser.
Instance Method Summary collapse
- #init_parser ⇒ Object
-
#initialize ⇒ Parser
constructor
A new instance of Parser.
- #parse(args) ⇒ Object
Constructor Details
#initialize ⇒ Parser
Returns a new instance of Parser.
9 10 11 12 |
# File 'lib/justy/parser.rb', line 9 def initialize super init_parser end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
6 7 8 |
# File 'lib/justy/parser.rb', line 6 def @options end |
#options_parser ⇒ Object (readonly)
Returns the value of attribute options_parser.
7 8 9 |
# File 'lib/justy/parser.rb', line 7 def @options_parser end |
Instance Method Details
#init_parser ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/justy/parser.rb', line 14 def init_parser @options_parser = OptionParser.new do|opts| opts. = "Usage: justy [options]" opts.on('-t', '--type type', 'Search type. Must be md5 or filename.') do |type| @options[:type] = type; end opts.on('-r', '--relative', 'Relative to current folder') do @options[:relative] = true end opts.on('-f', '--folder folder', 'Search folder') do |folder| @options[:folder] = folder end opts.on('-h', '--help', 'Displays Help') do puts opts exit end end end |
#parse(args) ⇒ Object
36 37 38 39 40 |
# File 'lib/justy/parser.rb', line 36 def parse(args) @options = {:type => nil, :folder => nil, :relative => false } .parse! return end |