Class: Grog::Options

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Options

Returns a new instance of Options.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/grog/options.rb', line 11

def initialize(argv)
  @opts = OptionParser.new

  @number_of_commits_to_show = 10
  @opts.on("-n=N", "number of commits to show", Integer) { |val| @number_of_commits_to_show = val }

  @show_datetimes = false
  @opts.on("-d", "show datetimes") { @show_datetimes = true }
  @opts.on_tail("-h", "--help", "Show this message") do
    puts @opts
    exit
  end
  @opts.on_tail("--version", "Show the version of the grog gem") do
    puts "grog v" + `cat VERSION`
  end

  @rest = @opts.parse(argv)
end

Instance Attribute Details

#number_of_commits_to_showObject

Returns the value of attribute number_of_commits_to_show.



5
6
7
# File 'lib/grog/options.rb', line 5

def number_of_commits_to_show
  @number_of_commits_to_show
end

#show_datetimesObject

Returns the value of attribute show_datetimes.



5
6
7
# File 'lib/grog/options.rb', line 5

def show_datetimes
  @show_datetimes
end

Class Method Details

.parse(argv) ⇒ Object



7
8
9
# File 'lib/grog/options.rb', line 7

def self.parse(argv)
  Options.new(argv)
end