class String

Constants

NON_WHITESPACE_REGEXP

0x3000: fullwidth whitespace

Public Instance Methods

blank?() click to toggle source

A string is blank if it's empty or contains whitespaces only:

"".blank?                 # => true
"   ".blank?              # => true
" ".blank?               # => true
" something here ".blank? # => false
# File lib/woolen_common/ruby_ext/blank.rb, line 100
def blank?
    if self == '[BLANK]'
        return true
    end
    # 1.8 does not takes [:space:] properly
    if encoding_aware?
        self !~ /[^[:space:]]/
    else
        self !~ NON_WHITESPACE_REGEXP
    end
end
is_na?() click to toggle source
# File lib/woolen_common/ruby_ext/blank.rb, line 111
def is_na?
    self.strip.upcase.include? 'NA'
end