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
#!=, #!~, #&, #<=>, #==, #===, #=~, #^, #eql?, #equal?, #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|on|enable)$/i
real_value = true
elsif value =~ /^(false|no|off|disable)$/i
real_value = false
end
if !!real_value == real_value
return true
end
false
end
|
Instance Method Details
#EnableDisable ⇒ Object
95
96
97
|
# File 'lib/semi/variables/boolean.rb', line 95
def EnableDisable
enabledisable.capitalize
end
|
#ENABLEDISABLE ⇒ Object
91
92
93
|
# File 'lib/semi/variables/boolean.rb', line 91
def ENABLEDISABLE
enabledisable.upcase
end
|
#enabledisable ⇒ Object
83
84
85
86
87
88
89
|
# File 'lib/semi/variables/boolean.rb', line 83
def enabledisable
if @value
'enable'
else
'disable'
end
end
|
#onoff ⇒ Object
49
50
51
52
53
54
55
|
# File 'lib/semi/variables/boolean.rb', line 49
def onoff
if @value
'on'
else
'off'
end
end
|
#ONOFF ⇒ Object
57
58
59
|
# File 'lib/semi/variables/boolean.rb', line 57
def ONOFF
onoff.upcase
end
|
#OnOff ⇒ Object
61
62
63
|
# File 'lib/semi/variables/boolean.rb', line 61
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
112
113
114
|
# File 'lib/semi/variables/boolean.rb', line 112
def TrueFalse
truefalse.capitalize
end
|
#TRUEFALSE ⇒ Object
108
109
110
|
# File 'lib/semi/variables/boolean.rb', line 108
def TRUEFALSE
truefalse.upcase
end
|
#truefalse ⇒ Object
100
101
102
103
104
105
106
|
# File 'lib/semi/variables/boolean.rb', line 100
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
66
67
68
69
70
71
72
|
# File 'lib/semi/variables/boolean.rb', line 66
def yesno()
if @value
'yes'
else
'no'
end
end
|
#YESNO ⇒ Object
74
75
76
|
# File 'lib/semi/variables/boolean.rb', line 74
def YESNO
yesno.upcase
end
|
#YesNo ⇒ Object
78
79
80
|
# File 'lib/semi/variables/boolean.rb', line 78
def YesNo
yesno.capitalize
end
|