class T::StringFormatted
Attributes
regex[R]
Public Class Methods
new(regex)
click to toggle source
# File lib/emery/type.rb, line 112 def initialize(regex) @regex = regex end
Public Instance Methods
check(value)
click to toggle source
# File lib/emery/type.rb, line 118 def check(value) T.check_not_nil(self, value) if !value.is_a? String raise TypeError.new("Value '#{value.inspect.to_s}' type is #{value.class} - String is required for StringFormatted") end if !@regex.match?(value) raise TypeError.new("Value '#{value.inspect.to_s}' is not in required format '#{@regex}'") end end
to_s()
click to toggle source
# File lib/emery/type.rb, line 115 def to_s "String<#@regex>" end