Module: CLLI::Pattern::ClassMethods
- Defined in:
- lib/clli/pattern.rb
Overview
These methods will be available in the CLLI class.
Constant Summary collapse
- DEFAULT_PATTERN_OPTIONS =
{ strict: true, place_group: 'place', region_group: 'region', network_site_group: 'network_site', entity_code_group: 'entity_code', nonbuilding_code_group: 'location_code', nonbuilding_id_group: 'location_id', customer_code_group: 'customer_code', customer_id_group: 'customer_id' }
Instance Method Summary collapse
-
#a ⇒ Object
A character group containing all alpha characters.
-
#a1 ⇒ Object
A character group excluding B, D, I, O, T, U, W, and Y.
-
#a2 ⇒ Object
A character group excluding G.
-
#customer_location_pattern(**options) ⇒ Object
Get the customer non-building location pattern.
-
#entity_code_pattern(**options) ⇒ Object
Get the entity code pattern.
-
#miscellaneous_switching_termination_entity_code_pattern ⇒ Object
Miscellaneous switching termination entities (Table D).
-
#n ⇒ Object
A character group containing all digit characters.
-
#network_site_pattern(**options) ⇒ Object
Get the network site code pattern.
-
#nonbuilding_location_pattern(**options) ⇒ Object
Get the non-building location code pattern.
-
#nonswitching_entity_code_pattern ⇒ Object
Non-Switching Entities (Table E).
-
#pattern(**options) ⇒ Object
Get the complete
CLLIpattern. -
#place_pattern(**options) ⇒ Object
Get the place abbreviation and region code pattern.
-
#regexp(**options) ⇒ Object
Get the complete
CLLIpattern as a compiledRegexp. - #relaxed_entity_code_pattern ⇒ Object
- #strict_entity_code_pattern ⇒ Object
-
#switchboard_and_desk_entity_code_pattern ⇒ Object
Switchboard and Desk Termination Entities (Table C).
-
#switching_entity_code_pattern ⇒ Object
Switching Entities (Table B).
-
#x ⇒ Object
A character group containing all alpha and digit characters.
-
#x1 ⇒ Object
A character group containing both
a1and all digit characters. -
#x2 ⇒ Object
A character group containing both
a2and all digit characters.
Instance Method Details
#a ⇒ Object
A character group containing all alpha characters.
168 169 170 |
# File 'lib/clli/pattern.rb', line 168 def a 'A-Z' end |
#a1 ⇒ Object
A character group excluding B, D, I, O, T, U, W, and Y.
156 157 158 |
# File 'lib/clli/pattern.rb', line 156 def a1 'ACE-HJ-NP-SVXZ' end |
#a2 ⇒ Object
A character group excluding G.
162 163 164 |
# File 'lib/clli/pattern.rb', line 162 def a2 'A-FH-Z' end |
#customer_location_pattern(**options) ⇒ Object
Get the customer non-building location pattern.
Params:
options-
see #pattern for more details.
148 149 150 151 152 |
# File 'lib/clli/pattern.rb', line 148 def customer_location_pattern(**) = DEFAULT_PATTERN_OPTIONS.merge() pattern = named_group([:customer_code_group], "[#{n}]") pattern << named_group([:customer_id_group], "[#{a}][#{n}]{3}") end |
#entity_code_pattern(**options) ⇒ Object
Get the entity code pattern.
Params:
options-
see #pattern for more details.
86 87 88 89 |
# File 'lib/clli/pattern.rb', line 86 def entity_code_pattern(**) = DEFAULT_PATTERN_OPTIONS.merge() named_group([:entity_code_group], [:strict] ? strict_entity_code_pattern : relaxed_entity_code_pattern) end |
#miscellaneous_switching_termination_entity_code_pattern ⇒ Object
Miscellaneous switching termination entities (Table D)
123 124 125 |
# File 'lib/clli/pattern.rb', line 123 def miscellaneous_switching_termination_entity_code_pattern ["[#{n}][AXCTWDEINPQ]D", "[#{x}][UM]D"].join('|') end |
#n ⇒ Object
A character group containing all digit characters.
174 175 176 |
# File 'lib/clli/pattern.rb', line 174 def n '0-9' end |
#network_site_pattern(**options) ⇒ Object
Get the network site code pattern.
Params:
options-
see #pattern for more details.
76 77 78 79 |
# File 'lib/clli/pattern.rb', line 76 def network_site_pattern(**) = DEFAULT_PATTERN_OPTIONS.merge() named_group([:network_site_group], [:strict] ? "(?:[#{a}]{2}|[#{n}]{2})" : "(?:[#{a}#{n}]{2})") end |
#nonbuilding_location_pattern(**options) ⇒ Object
Get the non-building location code pattern.
Params:
options-
see #pattern for more details.
137 138 139 140 141 |
# File 'lib/clli/pattern.rb', line 137 def nonbuilding_location_pattern(**) = DEFAULT_PATTERN_OPTIONS.merge() pattern = named_group([:nonbuilding_code_group], "[#{a}]") pattern << named_group([:nonbuilding_id_group], "[#{n}]{4}") end |
#nonswitching_entity_code_pattern ⇒ Object
Non-Switching Entities (Table E)
128 129 130 |
# File 'lib/clli/pattern.rb', line 128 def nonswitching_entity_code_pattern ["[FAEKMPSTW][#{x2}][#{x1}]", "Q[#{n}][#{n}]"].join('|') end |
#pattern(**options) ⇒ Object
Get the complete CLLI pattern.
Params:
options-
the following options are supported.
- :strict
-
whether or not the rules in section
795-100-100are enforced for all fields. - :place_group
-
the name to use for the place abbreviation.
- :region_group
-
the name to use for the region code.
- :network_site_group
-
the name to use for the network site code.
- :entity_code_group
-
the name to use for the entity code.
- :nonbuilding_code_group
-
the name to use for the nonbuilding code.
- :nonbuilding_id_group
-
the name to use for the nonbuilding ID.
- :customer_code_group
-
the name to use for the customer code.
- :customer_id_group
-
the name to use for the customer ID.
42 43 44 45 46 47 48 49 |
# File 'lib/clli/pattern.rb', line 42 def pattern(**) place = place_pattern() network_site = network_site_pattern() entity_code = entity_code_pattern() nonbuilding_location = nonbuilding_location_pattern() customer_location = customer_location_pattern() "\\A#{place}(?:#{network_site}(?:#{entity_code})?|#{nonbuilding_location}|#{customer_location})\\z" end |
#place_pattern(**options) ⇒ Object
Get the place abbreviation and region code pattern.
Params:
options-
see #pattern for more details.
65 66 67 68 69 |
# File 'lib/clli/pattern.rb', line 65 def place_pattern(**) = DEFAULT_PATTERN_OPTIONS.merge() pattern = named_group([:place_group], [:strict] ? "[#{a}]{4}|[#{a}]{3}[ ]|[#{a}]{2}[ ]{2}" : "[#{x}\s]{4}") pattern << named_group([:region_group], '[A-Z]{2}') end |
#regexp(**options) ⇒ Object
Get the complete CLLI pattern as a compiled Regexp.
Params:
options-
see #pattern for more details.
56 57 58 |
# File 'lib/clli/pattern.rb', line 56 def regexp(**) Regexp.new(pattern()) end |
#relaxed_entity_code_pattern ⇒ Object
100 101 102 |
# File 'lib/clli/pattern.rb', line 100 def relaxed_entity_code_pattern '[A-Z0-9]{3}' end |
#strict_entity_code_pattern ⇒ Object
91 92 93 94 95 96 97 98 |
# File 'lib/clli/pattern.rb', line 91 def strict_entity_code_pattern [ switching_entity_code_pattern, # (Table B) switchboard_and_desk_entity_code_pattern, # (Table C) miscellaneous_switching_termination_entity_code_pattern, # (Table D) nonswitching_entity_code_pattern # (Table E) ].join('|') end |
#switchboard_and_desk_entity_code_pattern ⇒ Object
Switchboard and Desk Termination Entities (Table C)
118 119 120 |
# File 'lib/clli/pattern.rb', line 118 def switchboard_and_desk_entity_code_pattern "[#{n}][CDBINQWMVROLPEUTZ#{n}]B" end |
#switching_entity_code_pattern ⇒ Object
Switching Entities (Table B)
105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/clli/pattern.rb', line 105 def switching_entity_code_pattern [ "(?:MG|SG|CG|DS|RL|PS|RP|CM|VS|OS|OL|[#{n}][#{n}])[#{x1}]", "[CB#{n}][#{n}]T", "[#{n}]GT", "Z[#{a}]Z", "RS[#{n}]", "X[#{a}]X", "CT[#{x1}]" ].join('|') end |
#x ⇒ Object
A character group containing all alpha and digit characters.
180 181 182 |
# File 'lib/clli/pattern.rb', line 180 def x a + n end |
#x1 ⇒ Object
A character group containing both a1 and all digit characters.
186 187 188 |
# File 'lib/clli/pattern.rb', line 186 def x1 a1 + n end |
#x2 ⇒ Object
A character group containing both a2 and all digit characters.
192 193 194 |
# File 'lib/clli/pattern.rb', line 192 def x2 a2 + n end |