Class: String
Overview
Adds the method from_user_input to various built-in classes as both a class and instance method. On a class, the method returns a validated instance of that class if it can be coerced into one (or nil if not). On an instance, it validates more strictly against the value of that instance.
Class Method Summary collapse
-
.from_user_input(value) ⇒ Object
All strings validate as strings.
Instance Method Summary collapse
-
#from_user_input(value) ⇒ Object
instance form does a straight comparison of the string with self.
Class Method Details
Instance Method Details
#from_user_input(value) ⇒ Object
instance form does a straight comparison of the string with self.
12 13 14 15 16 17 18 |
# File 'lib/user_input.rb', line 12 def from_user_input(value) if (self == value.to_s) return value.to_s else return nil end end |