Module: Peddler::Acronyms

Extended by:
Acronyms
Included in:
Acronyms
Defined in:
lib/peddler/acronyms.rb

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

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").

Parameters:

  • word (String)

Returns:

  • (String)


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

#valuesArray<String>

Returns Array of uppercase acronyms.

Returns:

  • (Array<String>)

    Array of uppercase acronyms



38
39
40
# File 'lib/peddler/acronyms.rb', line 38

def values
  MAP.values
end