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, #method_missing, #to_s, #value
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Semi::Variables::Base
Class Method Details
.validate(value) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/semi/variables/boolean.rb', line 27
def self.validate(value)
real_value = nil
if value.class == Semi::Variables::Boolean
value = value.to_s
end
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
94
95
96
|
# File 'lib/semi/variables/boolean.rb', line 94
def EnableDisable
enabledisable.capitalize
end
|
#ENABLEDISABLE ⇒ Object
90
91
92
|
# File 'lib/semi/variables/boolean.rb', line 90
def ENABLEDISABLE
enabledisable.upcase
end
|
#enabledisable ⇒ Object
82
83
84
85
86
87
88
|
# File 'lib/semi/variables/boolean.rb', line 82
def enabledisable
if @value
'enable'
else
'disable'
end
end
|
#onoff ⇒ Object
48
49
50
51
52
53
54
|
# File 'lib/semi/variables/boolean.rb', line 48
def onoff
if @value
'on'
else
'off'
end
end
|
#ONOFF ⇒ Object
56
57
58
|
# File 'lib/semi/variables/boolean.rb', line 56
def ONOFF
onoff.upcase
end
|
#OnOff ⇒ Object
60
61
62
|
# File 'lib/semi/variables/boolean.rb', line 60
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
111
112
113
|
# File 'lib/semi/variables/boolean.rb', line 111
def TrueFalse
truefalse.capitalize
end
|
#TRUEFALSE ⇒ Object
107
108
109
|
# File 'lib/semi/variables/boolean.rb', line 107
def TRUEFALSE
truefalse.upcase
end
|
#truefalse ⇒ Object
99
100
101
102
103
104
105
|
# File 'lib/semi/variables/boolean.rb', line 99
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
65
66
67
68
69
70
71
|
# File 'lib/semi/variables/boolean.rb', line 65
def yesno()
if @value
'yes'
else
'no'
end
end
|
#YESNO ⇒ Object
73
74
75
|
# File 'lib/semi/variables/boolean.rb', line 73
def YESNO
yesno.upcase
end
|
#YesNo ⇒ Object
77
78
79
|
# File 'lib/semi/variables/boolean.rb', line 77
def YesNo
yesno.capitalize
end
|