Module: Peddler::Acronyms
Overview
Handles acronym transformations for Amazon SP-API terminology
Constant Summary collapse
- MAP =
Mapping of camelized forms to their uppercase acronym equivalents
{ "Api" => "API", "Apis" => "APIs", "Asin" => "ASIN", "B2b" => "B2B", "Cgst" => "CGST", "Cod" => "COD", "Fba" => "FBA", "Igst" => "IGST", "Lwa" => "LWA", "Safet" => "SAFET", "Sgst" => "SGST", "Sku" => "SKU", "Tds" => "TDS", "Url" => "URL", "Urls" => "URLs", }.freeze
Instance Method Summary collapse
-
#apply(word) ⇒ String
Transforms acronyms in camelized words to uppercase equivalents.
-
#values ⇒ Array<String>
Array of uppercase acronyms.
Instance Method Details
#apply(word) ⇒ String
Transforms acronyms in camelized words to uppercase equivalents. Uses lookahead to prevent partial matches within words (e.g., "Cod" won't match inside "Code"). Plural forms require explicit mappings (e.g., "Urls" => "URLs").
33 34 35 |
# File 'lib/peddler/acronyms.rb', line 33 def apply(word) MAP.reduce(word) { |w, (from, to)| w.gsub(/#{from}(?=[A-Z]|$)/) { to } } end |
#values ⇒ Array<String>
Returns Array of uppercase acronyms.
38 39 40 |
# File 'lib/peddler/acronyms.rb', line 38 def values MAP.values end |