Class: SharedTools::Tools::CronTool
- Inherits:
-
RubyLLM::Tool
- Object
- RubyLLM::Tool
- SharedTools::Tools::CronTool
- Defined in:
- lib/shared_tools/tools/cron_tool.rb
Overview
Parse, validate, explain, and generate cron expressions.
Class Method Summary collapse
Instance Method Summary collapse
-
#execute(action:, expression: nil, count: nil, description: nil) ⇒ Hash
Result.
-
#initialize(logger: nil) ⇒ CronTool
constructor
A new instance of CronTool.
Constructor Details
Class Method Details
.name ⇒ Object
17 |
# File 'lib/shared_tools/tools/cron_tool.rb', line 17 def self.name = 'cron_tool' |
Instance Method Details
#execute(action:, expression: nil, count: nil, description: nil) ⇒ Hash
Returns result.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/shared_tools/tools/cron_tool.rb', line 53 def execute(action:, expression: nil, count: nil, description: nil) @logger.info("CronTool#execute action=#{action}") case action.to_s.downcase when 'parse' then parse_expression(expression) when 'validate' then validate_expression(expression) when 'next_times' then next_times(expression, (count || 5).to_i) when 'generate' then generate_expression(description) else { success: false, error: "Unknown action '#{action}'. Use: parse, validate, next_times, generate" } end rescue => e @logger.error("CronTool error: #{e.}") { success: false, error: e. } end |