Class: AWSCronParser::Validators::AWSRateValidator

Inherits:
Base
  • Object
show all
Defined in:
lib/aws_cron_parser/validators/aws_rate_validator.rb

Instance Attribute Summary

Attributes inherited from Base

#source

Instance Method Summary collapse

Methods inherited from Base

#initialize, validate

Methods included from Helpers

included

Constructor Details

This class inherits a constructor from AWSCronParser::Validators::Base

Instance Method Details

#validateObject

Raises:

  • (ArgumentError)


6
7
8
9
10
11
12
13
14
# File 'lib/aws_cron_parser/validators/aws_rate_validator.rb', line 6

def validate
  match = source.match(RATE_REGEX)
  raise ArgumentError, 'Invalid rate expression' unless match

  value = match[1].to_i
  raise ArgumentError, 'Rate value must be positive' if value <= 0

  true
end