Class: AtRandom::AtCmd

Inherits:
Object
  • Object
show all
Defined in:
lib/at-random/at_cmd.rb

Defined Under Namespace

Classes: InvalidTime

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ AtCmd

Returns a new instance of AtCmd.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/at-random/at_cmd.rb', line 5

def initialize(*args)
  if args[0]
    timespec = args.shift
    if !(timespec =~ /[0-2][0-9]:[0-5][0-9]/)
      raise ArgumentError
    end

    if timespec < Time.now.strftime('%H:%M')
      raise InvalidTime, "Timespec #{timespec} is earlier than now"
    end

    @exec_args = ['at', args, timespec].flatten
  end
end

Instance Method Details

#execObject



20
21
22
# File 'lib/at-random/at_cmd.rb', line 20

def exec
  Kernel.exec(*@exec_args)
end