Class: Pubid::Amca::Parser

Inherits:
Parslet::Parser
  • Object
show all
Defined in:
lib/pubid/amca/parser.rb

Overview

Parser class for ACMA identifiers Single Responsibility: Parsing ACMA identifier syntax

Class Method Summary collapse

Class Method Details

.parse(string) ⇒ Object



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/pubid/amca/parser.rb', line 136

def self.parse(string)
  # Strip leading/trailing whitespace
  cleaned = string.strip

  # Normalize multiple spaces to single space
  cleaned = cleaned.gsub(/\s+/, " ")

  # Normalize en dash to regular dash
  cleaned = cleaned.gsub("", "-")

  # Remove trailing periods and commas
  cleaned = cleaned.gsub(/[,.]$/, "")

  new.parse(cleaned)
end