class Wpxf::BooleanOption
A boolean option.
Public Instance Methods
false?(value)
click to toggle source
@param value the value to check. @return [Boolean] true if the value is a false boolean value.
# File lib/wpxf/core/opts/boolean_option.rb, line 33 def false?(value) !true?(value) end
normalize(value)
click to toggle source
@param value the value to normalize. @return [Boolean] a normalized value to conform with the type that.
the option is conveying.
# File lib/wpxf/core/opts/boolean_option.rb, line 21 def normalize(value) valid?(value) && !value.to_s.match(/^(y|yes|t|1|true)$/i).nil? end
true?(value)
click to toggle source
@param value the value to check. @return [Boolean] true if the value is a true boolean value.
# File lib/wpxf/core/opts/boolean_option.rb, line 27 def true?(value) normalize(value) end
valid?(value)
click to toggle source
Check if the specified value is valid in the context of this option. @param value the value to validate. @return [Boolean] true if valid.
# File lib/wpxf/core/opts/boolean_option.rb, line 10 def valid?(value) return false if empty_required_value?(value) return true if !required? && empty?(value) pattern = /^(y|yes|n|no|t|f|0|1|true|false)$/i value?(value) && !value.to_s.match(pattern).nil? end