Class: GS1::SyntaxDictionary::Parser::ColumnPatterns

Inherits:
Object
  • Object
show all
Defined in:
lib/gs1/syntax_dictionary/parser.rb

Overview

Patterns stolen from: github.com/gs1/gs1-syntax-engine/blob/f8b6345655fa9fa25ce1c5a11c5a317f9239529a/src/c-lib/build-embedded-ai-table.pl#L17-L100 The naming and extra indentation is to keep the code as close to the original Perl code above.

rubocop:disable Lint/DuplicateRegexpCharacterClassElement rubocop:disable Style/RegexpLiteral

Instance Method Summary collapse

Instance Method Details

#entry_rxObject

rubocop:disable Metrics/MethodLength



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/gs1/syntax_dictionary/parser.rb', line 114

def entry_rx
  /
      ^
      (?<ais>#{ai_rng_rx})
      (
          \s+
          (?<flags>#{flags_rx})
      )?
      \s+
      (?<spec>#{spec_rx})
      (
          \s+
          (?<keyvals>
              (#{keyval_rx}\s+)*
              #{keyval_rx}
          )
      )?
      (
          \s+
          \#
          \s
          (?<title>#{title_rx})
      )?
      \s*
      $
  /x
end