"Fossies" - the Fresh Open Source Software Archive

Member "asciidoctor-2.0.10/lib/asciidoctor/core_ext/nil_or_empty.rb" (1 Jun 2019, 645 Bytes) of package /linux/www/asciidoctor-2.0.10.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Ruby source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 # frozen_string_literal: true
    2 # A core library extension that defines the method nil_or_empty? as an alias to
    3 # optimize checks for nil? or empty? on common object types such as NilClass,
    4 # String, Array, Hash, and Numeric.
    5 
    6 class NilClass
    7   alias nil_or_empty? nil? unless method_defined? :nil_or_empty?
    8 end
    9 
   10 class String
   11   alias nil_or_empty? empty? unless method_defined? :nil_or_empty?
   12 end
   13 
   14 class Array
   15   alias nil_or_empty? empty? unless method_defined? :nil_or_empty?
   16 end
   17 
   18 class Hash
   19   alias nil_or_empty? empty? unless method_defined? :nil_or_empty?
   20 end
   21 
   22 class Numeric
   23   alias nil_or_empty? nil? unless method_defined? :nil_or_empty?
   24 end