Class: Regexp

Inherits:
Object show all
Defined in:
lib/user_input.rb

Instance Method Summary collapse

Instance Method Details

#from_user_input(value) ⇒ Object

Returns the string if value matches self’s regex, returns nil otherwise.



113
114
115
116
117
118
119
# File 'lib/user_input.rb', line 113

def from_user_input(value)
	if (value.kind_of?(String) && matches = self.match(value))
		return matches
	else
		return nil
	end
end