Sha256: def833e39119aa5828029137baa615477ec64f3ba757d99653c5d34805285dce

Contents?: true

Size: 770 Bytes

Versions: 5

Compression:

Stored size: 770 Bytes

Contents

module Langusta
  module Guard
    
    def self.klass(argument, klass, _method)
      return unless $debug
      raise TypeError.new("#{_method}: expected #{klass} got: #{argument.class}") unless argument.is_a?(klass)
    end
      
    def self.codepoint(codepoint, _method)
      return unless $debug
      raise ArgumentError.new([_method, ':', codepoint.to_s(16)].join) unless (0x0000..0xffff).include?(codepoint)
    end
    
    def self.codepoint_array(array, _method)
      return unless $debug
      raise TypeError.new("#{_method}: expected Array, got: #{array.class}") unless array.is_a?(Array)
      cp = array.find do |cp|
        ! (0x0000..0xffff).include?(cp)
      end && (raise ArgumentError.new("#{_method}: bad codepoint: #{cp}"))
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
langusta-0.2.4 lib/langusta/guard.rb
langusta-0.2.3 lib/langusta/guard.rb
langusta-0.2.2 lib/langusta/guard.rb
langusta-0.2.1 lib/langusta/guard.rb
langusta-0.2.0 lib/langusta/guard.rb