class Dice::Parser
Attributes
options[R]
Public Class Methods
new(args)
click to toggle source
# File lib/dice/parser.rb, line 8 def initialize(args) @options = {} @args = args end
Public Instance Methods
call()
click to toggle source
# File lib/dice/parser.rb, line 13 def call OptionParser.new do |parser| parser.banner = 'Usage: dice [options]' parser.version = Dice::VERSION parser.on('-f', '--faces N', Integer, 'Roll the dice with N faces.') do |faces| options[:faces] = faces end parser.on('-c', '--count COUNT', Integer, 'Roll the dice COUNT times.') do |count| options[:count] = count end parser.on('-h', '--help', 'Show this help message.') do puts parser exit end end.parse!(@args) end