Class: MisterBin::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/mister_bin/runner.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(basefile) ⇒ Runner

Returns a new instance of Runner.



9
10
11
12
13
# File 'lib/mister_bin/runner.rb', line 9

def initialize(basefile)
  @basefile = basefile
  @basedir = File.dirname basefile
  @name = File.basename basefile
end

Instance Attribute Details

#basedirObject (readonly)

Returns the value of attribute basedir.



3
4
5
# File 'lib/mister_bin/runner.rb', line 3

def basedir
  @basedir
end

#basefileObject (readonly)

Returns the value of attribute basefile.



3
4
5
# File 'lib/mister_bin/runner.rb', line 3

def basefile
  @basefile
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/mister_bin/runner.rb', line 3

def name
  @name
end

Class Method Details

.run(basefile, argv = []) ⇒ Object



5
6
7
# File 'lib/mister_bin/runner.rb', line 5

def self.run(basefile, argv=[])
  new(basefile).run argv
end

Instance Method Details

#run(argv = []) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/mister_bin/runner.rb', line 15

def run(argv=[])
  if argv.empty?
    show_subs
  else
    execute argv
  end
end