Class: Weigh::Flags

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Flags

Returns a new instance of Flags.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/weigh/flags.rb', line 11

def initialize(*args)
  @args     = []
  @verbose  = false
  @depth    = 1
  @pathlist = []

  @options = OptionParser.new do|o|
    o.banner = "Usage: #{File.basename $0} [options] [file|directory...]\n\n"

    o.on( '--verbose', '-v', 'Speak up' ) do
      @verbose = true
    end

    o.on( '--depth DEPTH', '-d', 'Sumarize deeper than DEPTH' ) do|d|
      @depth = d
    end

    o.on( '-h', '--help', 'Display this screen' ) do
      @help = true
    end
  end

  @args = @options.parse!

  if ARGV.size > 0
    ARGV.each do |f|
      @pathlist << f
    end
  else
    @pathlist << "."
  end

  def help?
    @help
  end
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



6
7
8
# File 'lib/weigh/flags.rb', line 6

def args
  @args
end

#depthObject (readonly)

Returns the value of attribute depth.



8
9
10
# File 'lib/weigh/flags.rb', line 8

def depth
  @depth
end

#pathlistObject (readonly)

Returns the value of attribute pathlist.



9
10
11
# File 'lib/weigh/flags.rb', line 9

def pathlist
  @pathlist
end

#verboseObject (readonly)

Returns the value of attribute verbose.



7
8
9
# File 'lib/weigh/flags.rb', line 7

def verbose
  @verbose
end

Instance Method Details

#help?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/weigh/flags.rb', line 43

def help?
  @help
end