Class: TiyoHw::Runners::Base
- Inherits:
-
Object
- Object
- TiyoHw::Runners::Base
- Defined in:
- lib/tiyo_hw/runners/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#commands ⇒ Object
readonly
Returns the value of attribute commands.
-
#pwd ⇒ Object
readonly
Returns the value of attribute pwd.
Class Method Summary collapse
Instance Method Summary collapse
- #add_command(cmd) ⇒ Object
- #file?(*args) ⇒ Boolean
- #file_contents?(regex, *args) ⇒ Boolean
- #file_path(*args) ⇒ Object
-
#initialize(pwd) ⇒ Base
constructor
A new instance of Base.
- #prepare_commands ⇒ Object
Constructor Details
#initialize(pwd) ⇒ Base
Returns a new instance of Base.
6 7 8 9 10 |
# File 'lib/tiyo_hw/runners/base.rb', line 6 def initialize(pwd) @commands = [] @pwd = pwd prepare_commands end |
Instance Attribute Details
#commands ⇒ Object (readonly)
Returns the value of attribute commands.
4 5 6 |
# File 'lib/tiyo_hw/runners/base.rb', line 4 def commands @commands end |
#pwd ⇒ Object (readonly)
Returns the value of attribute pwd.
4 5 6 |
# File 'lib/tiyo_hw/runners/base.rb', line 4 def pwd @pwd end |
Class Method Details
.get_commands(pwd) ⇒ Object
32 33 34 |
# File 'lib/tiyo_hw/runners/base.rb', line 32 def self.get_commands(pwd) self.new(pwd).commands end |
Instance Method Details
#add_command(cmd) ⇒ Object
12 13 14 |
# File 'lib/tiyo_hw/runners/base.rb', line 12 def add_command(cmd) @commands << cmd end |
#file?(*args) ⇒ Boolean
20 21 22 |
# File 'lib/tiyo_hw/runners/base.rb', line 20 def file?(*args) File.exist?(file_path(*args)) end |
#file_contents?(regex, *args) ⇒ Boolean
24 25 26 |
# File 'lib/tiyo_hw/runners/base.rb', line 24 def file_contents?(regex, *args) !File.readlines(file_path(*args)).grep(regex).empty? end |
#file_path(*args) ⇒ Object
16 17 18 |
# File 'lib/tiyo_hw/runners/base.rb', line 16 def file_path(*args) File.(File.join(pwd, *args)) end |
#prepare_commands ⇒ Object
28 29 30 |
# File 'lib/tiyo_hw/runners/base.rb', line 28 def prepare_commands raise NotImplementedError, "Subclases of Tiyo::Runners::Base must implement prepare_commands" end |