Class: Dirwatch::Options::Parser

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

Direct Known Subclasses

InitParser, WatchParser

Constant Summary collapse

COMMAND_NAME =
'dirwatch'.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(alternatives) ⇒ Parser

Returns a new instance of Parser.



20
21
22
# File 'lib/dirwatch/options/parser.rb', line 20

def initialize alternatives
  @alternatives = alternatives
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



18
19
20
# File 'lib/dirwatch/options/parser.rb', line 18

def options
  @options
end

Class Method Details

.from_args(args) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/dirwatch/options/parser.rb', line 9

def self.from_args args
  if args.first == 'init'
    args.shift
    InitParser.new [WatchParser.command_name]
  else
    WatchParser.new [InitParser.command_name]
  end
end

Instance Method Details

#actionObject



32
33
34
# File 'lib/dirwatch/options/parser.rb', line 32

def action
  self.class.action
end

#command_nameObject



28
29
30
# File 'lib/dirwatch/options/parser.rb', line 28

def command_name
  self.class.command_name
end

#parse!(args) ⇒ Object



24
25
26
# File 'lib/dirwatch/options/parser.rb', line 24

def parse! args
  build.parse! args
end