Class: Renamr::ASCIIValidatorAction

Inherits:
Action
  • Object
show all
Defined in:
lib/renamr/ascii_validator.rb

Overview

Checks if the resulted string has only ASCII symbols.

Instance Method Summary collapse

Methods inherited from Action

#p2m, #set

Instance Method Details

#do(src) ⇒ Object



11
12
13
14
15
16
# File 'lib/renamr/ascii_validator.rb', line 11

def do(src)
  ascii = src.chars.select(&:ascii_only?).join
  raise "String #{src} has non-ASCII symbols." if src != ascii

  src
end