Module: Flycal::DefaultSlots
- Defined in:
- lib/flycal/default_slots.rb
Overview
Built-in slot windows shared by Flycal core, HTTP API, and CLI setup.
CLI writes this fragment into ~/.flycal/config.yml on first load/setup, then reads templates from disk. API and MCP always read from this class, never from the user's home file.
Constant Summary collapse
- DEFAULTS =
{ "from" => "now", "default_duration" => "45min" }.freeze
- FREE_BEFORE =
"0m"- FREE_AFTER =
"15m"- EXCLUDE_CALENDARS =
[].freeze
Class Method Summary collapse
-
.as_json ⇒ Object
JSON-friendly payload for API / MCP
slots_templates. -
.config_fragment ⇒ Object
YAML-shaped Hash written into ~/.flycal/config.yml under
slots:. - .deep_dup(value) ⇒ Object
- .defaults ⇒ Object
- .exclude_calendars ⇒ Object
- .free_after ⇒ Object
- .free_before ⇒ Object
- .names ⇒ Object
- .templates ⇒ Object
Class Method Details
.as_json ⇒ Object
JSON-friendly payload for API / MCP slots_templates.
57 58 59 60 61 62 63 64 |
# File 'lib/flycal/default_slots.rb', line 57 def as_json { "templates" => deep_dup(templates), "defaults" => deep_dup(defaults), "free_before" => free_before, "free_after" => free_after } end |
.config_fragment ⇒ Object
YAML-shaped Hash written into ~/.flycal/config.yml under slots:.
46 47 48 49 50 51 52 53 54 |
# File 'lib/flycal/default_slots.rb', line 46 def config_fragment { "templates" => deep_dup(templates), "exclude_calendars" => exclude_calendars.dup, "defaults" => deep_dup(defaults), "free_before" => free_before, "free_after" => free_after } end |
.deep_dup(value) ⇒ Object
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/flycal/default_slots.rb', line 66 def deep_dup(value) case value when Hash value.transform_values { |item| deep_dup(item) } when Array value.map { |item| deep_dup(item) } else value end end |
.defaults ⇒ Object
29 30 31 |
# File 'lib/flycal/default_slots.rb', line 29 def defaults DEFAULTS end |
.exclude_calendars ⇒ Object
41 42 43 |
# File 'lib/flycal/default_slots.rb', line 41 def exclude_calendars EXCLUDE_CALENDARS end |
.free_after ⇒ Object
37 38 39 |
# File 'lib/flycal/default_slots.rb', line 37 def free_after FREE_AFTER end |
.free_before ⇒ Object
33 34 35 |
# File 'lib/flycal/default_slots.rb', line 33 def free_before FREE_BEFORE end |
.names ⇒ Object
25 26 27 |
# File 'lib/flycal/default_slots.rb', line 25 def names SlotTemplates.names(templates) end |
.templates ⇒ Object
21 22 23 |
# File 'lib/flycal/default_slots.rb', line 21 def templates SlotTemplates::BUILTIN end |