Class: Iz::Alphanumeric
- Inherits:
-
Object
- Object
- Iz::Alphanumeric
- Defined in:
- lib/iz/alphanumeric.rb
Constant Summary collapse
- REGEX =
/^[a-z0-9]+$/i
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(alphanumeric) ⇒ Alphanumeric
constructor
A new instance of Alphanumeric.
- #valid? ⇒ Boolean
Constructor Details
#initialize(alphanumeric) ⇒ Alphanumeric
Returns a new instance of Alphanumeric.
7 8 9 |
# File 'lib/iz/alphanumeric.rb', line 7 def initialize(alphanumeric) self.value = alphanumeric end |
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
5 6 7 |
# File 'lib/iz/alphanumeric.rb', line 5 def value @value end |
Class Method Details
.is_alphanumeric?(value) ⇒ Boolean
15 16 17 18 |
# File 'lib/iz/alphanumeric.rb', line 15 def self.is_alphanumeric?(value) return false unless value value.to_s =~ REGEX end |
Instance Method Details
#valid? ⇒ Boolean
11 12 13 |
# File 'lib/iz/alphanumeric.rb', line 11 def valid? !!Iz::Alphanumeric.is_alphanumeric?(value) end |