Sha256: b23df7fddba9fd4cb712bfcb09bc1957cd0efb05f04e4492757b0147a773e3bc

Contents?: true

Size: 446 Bytes

Versions: 7

Compression:

Stored size: 446 Bytes

Contents

class Symbol

  # Does a symbol have a "not" sign?
  #
  #   "friend".to_sym.not?   #=> false
  #   "~friend".to_sym.not?  #=> true
  #
  #  CREDIT: Trans

  def not?
    self.to_s.slice(0,1) == '~'
  end

  # Add a "not" sign to the front of a symbol.
  #
  #   ~:friend    #=> :"~friend"
  #
  #  CREDIT: Trans

  def ~@
    if self.to_s.slice(0,1) == '~'
      "#{self.to_s[1..-1]}".to_sym
    else
      "~#{self}".to_sym
    end
  end

end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
facets-2.4.0 lib/facets/symbol/not.rb
facets-2.4.1 lib/facets/symbol/not.rb
facets-2.4.2 lib/core/facets/symbol/not.rb
facets-2.4.3 lib/core/facets/symbol/not.rb
facets-2.4.4 lib/core/facets/symbol/not.rb
facets-2.4.5 lib/core/facets/symbol/not.rb
mack-facets-0.8.2 lib/gems/facets-2.4.5/lib/core/facets/symbol/not.rb