Sha256: 53dcb425d361888f605137307c27e2db73bb7e722eafd5fe5e33e9ceaf048b7e
Contents?: true
Size: 900 Bytes
Versions: 50
Compression:
Stored size: 900 Bytes
Contents
# frozen_string_literal: true require 'singleton' # Use the Singleton design pattern require_relative 'boolean' module Loxxy module Datatype # Class for representing a Lox true value. class True < Boolean include Singleton # Make a singleton class # Build the sole instance def initialize super(true) end # Is this object representing the true value in Lox? # @return [TrueClass] def true? true end # Check for equality of a Lox True with another Lox object / Ruby true # @param other [Datatype::True, TrueClass, Object] # @return [Datatype::Boolean] def ==(other) thruthy = other.kind_of?(True) || other.kind_of?(TrueClass) thruthy ? True.instance : False.instance end end # class True.instance.freeze # Make the sole instance immutable end # module end # module
Version data entries
50 entries across 50 versions & 1 rubygems