Class: OtbJobQueue::JobsParser
- Inherits:
-
Object
- Object
- OtbJobQueue::JobsParser
- Defined in:
- lib/otb_job_queue/jobs_parser.rb
Overview
Parses a string of jobs into an hash
Defined Under Namespace
Classes: InputError
Constant Summary collapse
- JOBS_QUEUE_FORMAT =
/(\w) => (\w|)/.freeze
- Schema =
JobsParser’s Validation schema Successful validation if input is an empty String or a String of valid format
Dry::Validation.Schema do required(:jobs_input) { type?(String) & (empty? | format?(JOBS_QUEUE_FORMAT)) } end
Class Method Summary collapse
-
.call(jobs_input) ⇒ JobsParser.new(jobs_input).call, InputError
Creates a new JobsParser instance and calls the .call method on it.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(jobs_input) ⇒ JobsParser
constructor
Creates a new instance of the JobsParser with the valid jobs_input param.
Constructor Details
#initialize(jobs_input) ⇒ JobsParser
Creates a new instance of the JobsParser with the valid jobs_input param
16 17 18 |
# File 'lib/otb_job_queue/jobs_parser.rb', line 16 def initialize(jobs_input) @jobs_input = jobs_input end |
Class Method Details
.call(jobs_input) ⇒ JobsParser.new(jobs_input).call, InputError
Creates a new JobsParser instance and calls the .call method on it
34 35 36 37 38 39 40 41 |
# File 'lib/otb_job_queue/jobs_parser.rb', line 34 def self.call(jobs_input) validation = self::Schema.call(jobs_input: jobs_input) if validation.success? new(jobs_input).call else raise InputError, validation. end end |
Instance Method Details
#call ⇒ Object
43 44 45 |
# File 'lib/otb_job_queue/jobs_parser.rb', line 43 def call parse end |