Sha256: 7973c162475215bcc046c316bf5c8d02e50d20bba7b053bf2a0dac0c6a0b86dd

Contents?: true

Size: 1.46 KB

Versions: 3

Compression:

Stored size: 1.46 KB

Contents

class NilClass {
  """
  NilClass. The class of the singleton @nil value.
  """

  def NilClass new {
    """
    @return @nil.
    """

    # always return nil singleton object when trying to create a new
    # NilClass instance
    nil
  }

  def if_true: block {
    """
    @return @nil.
    """

    nil
  }

  def if_true: then_block else: else_block {
    """
    @return Value of calling @else_block.

    Calls @else_block.
    """
    else_block call
  }

  def if_nil: block {
    """
    @block @Block@ to be called.
    @return Value of calling @block with @self.

    Calls @block with @self.
    """

    block call: [self]
  }

  def if_nil: then_block else: else_block {
    """
    @then_block @Block@ to be called with @self.
    @else_block Gets ignored.
    @return Value of calling @then_block with @self.

    Calls @then_block with @self.
    """

    then_block call: [self]
  }

  def nil? {
    """
    @return @true.
    """

    true
  }

  def to_s {
    """
    @return An empty @String@.
    """

    ""
  }

  alias_method: 'inspect for: 'to_s

  def to_a {
    """
    @return An empty @Array@.
    """

    []
  }

  def to_hash {
    """
    @return An empty @Hash@.
    """

    <[]>
  }

  def not {
    """
    @return @true.
    """

    true
  }

  def inspect {
    """
    @return @nil as a @String@.
    """

    "nil"
  }
}

nil documentation: """
  @nil is the singleton nil value (only instance of @NilClass@).
  NilClass##new yields @nil.
  """

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fancy-0.10.0 lib/nil_class.fy
fancy-0.9.0 lib/nil_class.fy
fancy-0.8.0 lib/nil_class.fy