Sha256: e8691eb943eefc41bf6d0817d23b7590e3bf9bdfa9c45976083e3089ef17e6aa

Contents?: true

Size: 643 Bytes

Versions: 6

Compression:

Stored size: 643 Bytes

Contents

class Symbol

  # Symbol does not end in `!`, `=`, or `?`.
  #
  #   :a.plain?   #=> true
  #   :a?.plain?  #=> false
  #   :a!.plain?  #=> false
  #   :a=.plain?  #=> false
  #
  def plain?
    c = to_s[-1,1]
    !(c == '=' || c == '?' || c == '!')
  end

  # Symbol ends in `=`.
  #
  #   :a=.setter? #=> true
  #   :a.setter?  #=> false
  #
  def setter?
    to_s[-1,1] == '='
  end

  # Symbol ends in `?`.
  #
  #   :a?.query? #=> true
  #   :a.query?  #=> false
  #
  def query?
    to_s[-1,1] == '?'
  end

  # Symbol ends in `!`.
  #
  #   :a!.bang? #=> true
  #   :a.bang?  #=> false
  #
  def bang?
    to_s[-1,1] == '!'
  end

end

Version data entries

6 entries across 5 versions & 1 rubygems

Version Path
facets-2.9.2 lib/core/facets/symbol/plain.rb
facets-2.9.2 src/core/facets/symbol/plain.rb
facets-2.9.1 lib/core/facets/symbol/plain.rb
facets-2.9.0 lib/core/facets/symbol/plain.rb
facets-2.9.0.pre.2 lib/core/facets/symbol/plain.rb
facets-2.9.0.pre.1 lib/core/facets/symbol/plain.rb