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
CLLI
pattern. -
#place_pattern(**options) ⇒ Object
Get the place abbreviation and region code pattern.
-
#regexp(**options) ⇒ Object
Get the complete
CLLI
pattern as a compiledRegexp
. -
#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
a1
and all digit characters. -
#x2 ⇒ Object
A character group containing both
a2
and all digit characters.
Instance Method Details
#a ⇒ Object
A character group containing all alpha characters.
160 161 162 |
# File 'lib/clli/pattern.rb', line 160 def a 'A-Z' end |
#a1 ⇒ Object
A character group excluding B, D, I, O, T, U, W, and Y.
148 149 150 |
# File 'lib/clli/pattern.rb', line 148 def a1 'ACE-HJ-NP-SVXZ' end |
#a2 ⇒ Object
A character group excluding G.
154 155 156 |
# File 'lib/clli/pattern.rb', line 154 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.
140 141 142 143 144 |
# File 'lib/clli/pattern.rb', line 140 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 90 91 92 93 94 |
# File 'lib/clli/pattern.rb', line 86 def entity_code_pattern(**) = DEFAULT_PATTERN_OPTIONS.merge() named_group([:entity_code_group], [ 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 |
#miscellaneous_switching_termination_entity_code_pattern ⇒ Object
Miscellaneous switching termination entities (Table D)
115 116 117 |
# File 'lib/clli/pattern.rb', line 115 def miscellaneous_switching_termination_entity_code_pattern ["[#{n}][AXCTWDEINPQ]D", "[#{x}][UM]D"].join('|') end |
#n ⇒ Object
A character group containing all digit characters.
166 167 168 |
# File 'lib/clli/pattern.rb', line 166 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.
129 130 131 132 133 |
# File 'lib/clli/pattern.rb', line 129 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)
120 121 122 |
# File 'lib/clli/pattern.rb', line 120 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-100
are 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() "#{place}(?:#{network_site}(?:#{entity_code})?|#{nonbuilding_location}|#{customer_location})" 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 |
#switchboard_and_desk_entity_code_pattern ⇒ Object
Switchboard and Desk Termination Entities (Table C)
110 111 112 |
# File 'lib/clli/pattern.rb', line 110 def switchboard_and_desk_entity_code_pattern "[#{n}][CDBINQWMVROLPEUTZ#{n}]B" end |
#switching_entity_code_pattern ⇒ Object
Switching Entities (Table B)
97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/clli/pattern.rb', line 97 def switching_entity_code_pattern [ "(?:MG|SG|CG|DS|[#{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.
172 173 174 |
# File 'lib/clli/pattern.rb', line 172 def x a + n end |
#x1 ⇒ Object
A character group containing both a1
and all digit characters.
178 179 180 |
# File 'lib/clli/pattern.rb', line 178 def x1 a1 + n end |
#x2 ⇒ Object
A character group containing both a2
and all digit characters.
184 185 186 |
# File 'lib/clli/pattern.rb', line 184 def x2 a2 + n end |