Sha256: 22e372a552cff6f23eb241718c0687faa39d42233ca37462bd51df0ff7021940

Contents?: true

Size: 444 Bytes

Versions: 10

Compression:

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

10 entries across 9 versions & 2 rubygems

Version Path
facets-glimmer-3.2.0 lib/core/facets/symbol/not.rb
facets-3.1.0 lib/core/facets/symbol/not.rb
facets-3.0.0 lib/core/facets/symbol/not.rb
facets-2.9.3 lib/core/facets/symbol/not.rb
facets-2.9.2 src/core/facets/symbol/not.rb
facets-2.9.2 lib/core/facets/symbol/not.rb
facets-2.9.1 lib/core/facets/symbol/not.rb
facets-2.9.0 lib/core/facets/symbol/not.rb
facets-2.9.0.pre.2 lib/core/facets/symbol/not.rb
facets-2.9.0.pre.1 lib/core/facets/symbol/not.rb