-
Notifications
You must be signed in to change notification settings - Fork 1
/
hsms_state.rb
90 lines (71 loc) · 1.21 KB
/
hsms_state.rb
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
class ConnectState
attr_reader :is_connect
def initialize
@is_connect = false
end
def to_s
if @is_connect
"CONNECTED"
else
"NOT CONNECTED"
end
end
def connected
@is_connect = true
end
def disconnected
@is_connect = false
end
end
class SelectState
attr_reader :is_select
def initialize
@is_select = false
end
def to_s
if @is_select
"SELECTED"
else
"NOT SELECTED"
end
end
def selected
@is_select = true
end
def deselected
@is_select = false
end
end
class HSMSState
attr_reader :connect_state
attr_reader :select_state
def initialize
@connect_state = ConnectState.new
@select_state = SelectState.new
end
def to_s
"HSMS Status: " + connect_state.to_s + ", " + select_state.to_s
end
def is_connect
@connect_state.is_connect
end
def is_select
@select_state.is_select
end
def connected
@connect_state.connected
end
def disconnected
deselected
@connect_state.disconnected
end
def can_select
connected
end
def selected
@select_state.selected if can_select
end
def deselected
@select_state.deselected
end
end