Class: Kali::Type::Boolean
Instance Method Summary
collapse
Methods inherited from Kali::Type
#decode, #encode, #parameters
Constructor Details
#initialize(requirement = nil) ⇒ Boolean
Returns a new instance of Boolean.
3
4
5
|
# File 'lib/kali/type/boolean.rb', line 3
def initialize(requirement = nil)
super(->(o) { (o == true || o == false) && (requirement.nil? || requirement === o) })
end
|
Instance Method Details
#decode!(string) ⇒ Object
11
12
13
14
15
16
|
# File 'lib/kali/type/boolean.rb', line 11
def decode!(string)
case string
when "TRUE"; true
when "FALSE"; false
end
end
|
#encode!(flag) ⇒ Object
7
8
9
|
# File 'lib/kali/type/boolean.rb', line 7
def encode!(flag)
flag ? "TRUE" : "FALSE"
end
|