Module: Langusta::Guard
- Defined in:
- lib/langusta/guard.rb
Class Method Summary collapse
- .codepoint(codepoint, _method) ⇒ Object
- .codepoint_array(array, _method) ⇒ Object
- .klass(argument, klass, _method) ⇒ Object
Class Method Details
.codepoint(codepoint, _method) ⇒ Object
9 10 11 12 |
# File 'lib/langusta/guard.rb', line 9 def self.codepoint(codepoint, _method) return unless $debug raise ArgumentError.new([_method, ':', codepoint.to_s(16)].join) unless (0x0000..0xffff).include?(codepoint) end |
.codepoint_array(array, _method) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/langusta/guard.rb', line 14 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 |
.klass(argument, klass, _method) ⇒ Object
4 5 6 7 |
# File 'lib/langusta/guard.rb', line 4 def self.klass(argument, klass, _method) return unless $debug raise TypeError.new("#{_method}: expected #{klass} got: #{argument.class}") unless argument.is_a?(klass) end |