Sha256: 1c6aa9e041b74fff57a71c627355a22a47fd195b12d08310dd75dd51310d806e

Contents?: true

Size: 448 Bytes

Versions: 2

Compression:

Stored size: 448 Bytes

Contents

# -*- encoding : utf-8 -*-
require 'singleton'

module Megingiard
  # The given ANSI escape sequence was not valid
  class InvalidAnsiEscapeCode < ArgumentError
  end

  # Validator for ANSI escape sequence
  class AnsiEscapeCodeValidator
    include Singleton

    VALID_ESCAPE_CODES = 0..55

    # Validate an ANSI escape sequence
    def validate(code)
      fail InvalidAnsiEscapeCode unless VALID_ESCAPE_CODES.include?(code)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
megingiard-0.1.0 lib/megingiard/ansi_escape_code_validator.rb
megingiard-0.0.1 lib/megingiard/ansi_escape_code_validator.rb