Class: OmnifocusMcp::Infrastructure::AppleScriptDateBuilder
- Inherits:
-
Object
- Object
- OmnifocusMcp::Infrastructure::AppleScriptDateBuilder
- Defined in:
- lib/omnifocus_mcp/infrastructure/apple_script_date_builder.rb
Overview
Builds AppleScript date fragments outside tell blocks so date variables can be safely referenced inside OmniFocus tell blocks.
Defined Under Namespace
Classes: DateAssignmentParts
Constant Summary collapse
- ISO_DATE_ONLY_RE =
/\A\d{4}-\d{2}-\d{2}\z/
Class Method Summary collapse
-
.create_date_outside_tell_block(iso_date_string, var_name) ⇒ Object
Generate AppleScript to construct a date variable outside ‘tell` blocks.
-
.generate_date_assignment(object_name, property_name, iso_date_string) ⇒ Object
Return the scripts needed to assign or clear a date property.
Class Method Details
.create_date_outside_tell_block(iso_date_string, var_name) ⇒ Object
Generate AppleScript to construct a date variable outside ‘tell` blocks.
17 18 19 |
# File 'lib/omnifocus_mcp/infrastructure/apple_script_date_builder.rb', line 17 def create_date_outside_tell_block(iso_date_string, var_name) emit_date_assignment(parse_iso(iso_date_string), var_name) end |
.generate_date_assignment(object_name, property_name, iso_date_string) ⇒ Object
Return the scripts needed to assign or clear a date property.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/omnifocus_mcp/infrastructure/apple_script_date_builder.rb', line 22 def generate_date_assignment(object_name, property_name, iso_date_string) return nil if iso_date_string.nil? if iso_date_string == "" return DateAssignmentParts.new( pre_script: "", assignment_script: "set #{property_name} of #{object_name} to missing value" ) end var_name = "dateVar#{SecureRandom.hex(5)}" DateAssignmentParts.new( pre_script: create_date_outside_tell_block(iso_date_string, var_name), assignment_script: "set #{property_name} of #{object_name} to #{var_name}" ) end |