Class: Weigh::CLI

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(flags) ⇒ CLI

Returns a new instance of CLI.



10
11
12
13
# File 'lib/weigh/cli.rb', line 10

def initialize(flags)
  @flags  = flags
  @runner = Weigh::Runner.new(@flags)
end

Instance Attribute Details

#flagsObject (readonly)

Returns the value of attribute flags.



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

def flags
  @flags
end

#runnerObject (readonly)

Returns the value of attribute runner.



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

def runner
  @runner
end

Class Method Details

.run(*args) ⇒ Object



24
25
26
27
28
# File 'lib/weigh/cli.rb', line 24

def self.run(*args)
  flags = Weigh::Flags.new args

  return Weigh::CLI.new(flags).run
end

Instance Method Details

#runObject



15
16
17
18
19
20
21
22
# File 'lib/weigh/cli.rb', line 15

def run
  if flags.help?
    puts flags
    exit
  end

  runner.run
end