Class: Semi::Variables::Boolean
- Inherits:
-
Base
- Object
- Base
- Semi::Variables::Boolean
show all
- Defined in:
- lib/semi/variables/boolean.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #to_s, #value
Class Method Details
.validate(value) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/semi/variables/boolean.rb', line 27
def self.validate(value)
real_value = nil
if value =~ /true|yes|enable/i
real_value = true
elsif value =~ /false|no|disable/i
real_value = false
end
if !!real_value == real_value
return true
end
false
end
|
Instance Method Details
#EnableDisable ⇒ Object
89
90
91
|
# File 'lib/semi/variables/boolean.rb', line 89
def EnableDisable
enabledisable.capitalize
end
|
#ENABLEDISABLE ⇒ Object
85
86
87
|
# File 'lib/semi/variables/boolean.rb', line 85
def ENABLEDISABLE
enabledisable.upcase
end
|
#enabledisable ⇒ Object
77
78
79
80
81
82
83
|
# File 'lib/semi/variables/boolean.rb', line 77
def enabledisable
if @value
'enable'
else
'disable'
end
end
|
#onoff ⇒ Object
43
44
45
46
47
48
49
|
# File 'lib/semi/variables/boolean.rb', line 43
def onoff
if @value
'on'
else
'off'
end
end
|
#ONOFF ⇒ Object
51
52
53
|
# File 'lib/semi/variables/boolean.rb', line 51
def ONOFF
onoff.upcase
end
|
#OnOff ⇒ Object
55
56
57
|
# File 'lib/semi/variables/boolean.rb', line 55
def OnOff
onoff.capitalize
end
|
#set(val) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/semi/variables/boolean.rb', line 7
def set(val)
if val.instance_of? TrueClass
@value = true
elsif val.instance_of? FalseClass
@value = false
elsif val =~ /true|yes|on|enable/i
@value = true
elsif val =~ /false|no|off|disable/i
@value = false
else
raise Semi::VariableError, "#{val} trying to be set as a boolean"
end
end
|
#TrueFalse ⇒ Object
106
107
108
|
# File 'lib/semi/variables/boolean.rb', line 106
def TrueFalse
truefalse.capitalize
end
|
#TRUEFALSE ⇒ Object
102
103
104
|
# File 'lib/semi/variables/boolean.rb', line 102
def TRUEFALSE
truefalse.upcase
end
|
#truefalse ⇒ Object
94
95
96
97
98
99
100
|
# File 'lib/semi/variables/boolean.rb', line 94
def truefalse
if @value
'true'
else
'false'
end
end
|
#validate ⇒ Object
23
24
25
|
# File 'lib/semi/variables/boolean.rb', line 23
def validate
self.validate(@value)
end
|
#yesno ⇒ Object
60
61
62
63
64
65
66
|
# File 'lib/semi/variables/boolean.rb', line 60
def yesno()
if @value
'yes'
else
'no'
end
end
|
#YESNO ⇒ Object
68
69
70
|
# File 'lib/semi/variables/boolean.rb', line 68
def YESNO
yesno.upcase
end
|
#YesNo ⇒ Object
72
73
74
|
# File 'lib/semi/variables/boolean.rb', line 72
def YesNo
yesno.capitalize
end
|