-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheartbeat_rule_editor.cr
33 lines (29 loc) · 1.03 KB
/
heartbeat_rule_editor.cr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# State for a heartbeat rule editor. Almost identical to
# `KeywordRuleEditorState`, hence the subclassing.
class HeartbeatRuleEditorState < KeywordRuleEditorState
def new_substate_for(index : Int)
{HeartbeatRuleHeaderState, RuleCodeRowState}[index].new
end
end
# View for a heartbeat rule editor. Looks almost identical
# to `KeywordRuleEditorView`, hence the subclassing.
class HeartbeatRuleEditorView < KeywordRuleEditorView
def new_subview_for(index : Int)
{HeartbeatRuleHeaderView, RuleCodeRowView}[index].new
end
end
# Heartbeat rule editor allows to create and edit a heartbeat rule.
#
# Heartbeat rules are rules whose expression happens on every tick,
# or after a period if this period is specified.
class HeartbeatRuleEditor < RuleEditor
include MonoBufferController(HeartbeatRuleEditorState, HeartbeatRuleEditorView)
include BufferEditorHandler
include BufferEditorRowHandler
include KeywordRuleEditorHandler
include CellEditorEntity
include RuleEditorHandler
def to_rule : Rule
@state.to_rule
end
end