Sha256: 63bc9739493d86ed69dba5432c8a6650513a64aa63a8fd9f1f5fa224dc88f5e4
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
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 # @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 # Check for inequality of a Lox True with another Lox object # @param other [Datatype::BuiltinDatatype, TrueClass, Object] # @return [Datatype::Boolean] def !=(other) thruthy = other.kind_of?(True) || other.kind_of?(TrueClass) thruthy ? False.instance : True.instance end end # class True.instance.freeze # Make the sole instance immutable end # module end # module
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
loxxy-0.0.16 | lib/loxxy/datatype/true.rb |