class Wpxf::StringOption
A string option.
Public Instance Methods
normalize(value)
click to toggle source
@param value the value to normalize. If a string starting with
"file:" is specified, the path following it will be used to populate the value from the contents of the file.
@return [String] a normalized value to conform with the type that
the option is conveying.
# File lib/wpxf/core/opts/string_option.rb, line 11 def normalize(value) match = value&.match(/^file:(.*)/) if match path = match[1] begin value = File.read(path) rescue ::Errno::ENOENT, ::Errno::EISDIR value = nil end end 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.
Calls superclass method
Wpxf::Option#valid?
# File lib/wpxf/core/opts/string_option.rb, line 28 def valid?(value) value = normalize(value) super(value) end