Sha256: 89e7bccc77ae9e0608de68474d66b9abf78b9f70fac7c2360e035c0b5810e2b4

Contents?: true

Size: 447 Bytes

Versions: 3

Compression:

Stored size: 447 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

3 entries across 3 versions & 1 rubygems

Version Path
facets-2.2.0 lib/core/facets/symbol/not.rb
facets-2.2.1 lib/core/facets/symbol/not.rb
facets-2.3.0 lib/core/facets/symbol/not.rb