Class: RsyncCron::Command
- Inherits:
-
Object
- Object
- RsyncCron::Command
- Defined in:
- lib/rsync_cron/command.rb
Constant Summary collapse
- NAME =
`which rsync`.strip
Instance Method Summary collapse
-
#initialize(src:, dest:, options: Options.new, name: NAME, log: nil, io: STDOUT) ⇒ Command
constructor
A new instance of Command.
- #to_s ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(src:, dest:, options: Options.new, name: NAME, log: nil, io: STDOUT) ⇒ Command
Returns a new instance of Command.
7 8 9 10 11 12 13 14 |
# File 'lib/rsync_cron/command.rb', line 7 def initialize(src:, dest:, options: Options.new, name: NAME, log: nil, io: STDOUT) @src = src @dest = dest = @name = name @log = log @io = io end |
Instance Method Details
#to_s ⇒ Object
16 17 18 19 |
# File 'lib/rsync_cron/command.rb', line 16 def to_s return @io.puts "rsync not installed" if @name.empty? "#{@name} #{@options} #{@src} #{@dest}#{log}" end |
#valid? ⇒ Boolean
21 22 23 24 25 26 27 |
# File 'lib/rsync_cron/command.rb', line 21 def valid? [@src, @dest].all? do |host| host.exist?.tap do |check| @io.puts "#{host} does not exist" unless check end end end |