Class: PIC::Template
Overview
Template class encapsulates a picture string, converts it to a regular expression, and delegates to it for matching.
Instance Attribute Summary collapse
-
#pic ⇒ String
readonly
The picture string.
Instance Method Summary collapse
-
#!~(string) ⇒ Boolean
Check for non-match of the picture against a given string.
-
#=~(string) ⇒ Integer?
(also: #===)
Match picture against a given string.
-
#initialize(pic) ⇒ Template
constructor
New pic template.
-
#to_re ⇒ Regexp
(also: #to_regexp)
Convert picture to a regular expression.
Constructor Details
#initialize(pic) ⇒ Template
New pic template.
81 82 83 |
# File 'lib/standard/facets/pic.rb', line 81 def initialize(pic) @pic = pic end |
Instance Attribute Details
#pic ⇒ String (readonly)
The picture string.
89 90 91 |
# File 'lib/standard/facets/pic.rb', line 89 def pic @pic end |
Instance Method Details
#!~(string) ⇒ Boolean
Check for non-match of the picture against a given string.
129 130 131 |
# File 'lib/standard/facets/pic.rb', line 129 def !~(string) to_re !~ string.to_str end |
#=~(string) ⇒ Integer? Also known as: ===
Match picture against a given string.
116 117 118 |
# File 'lib/standard/facets/pic.rb', line 116 def =~(string) to_re =~ string.to_str end |