Sha256: 2a45939a251c0ee1214e36887ea9d9ca5414d1e6b275a65c868df5103540135f
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 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 false value. class False < Boolean include Singleton # Make a singleton class # Build the sole instance def initialize super(false) end # Is this object representing a false value in Lox? # @return [TrueClass] def false? true end # Check for equality of a Lox False with another Lox object # @param other [Datatype::BuiltinDatatype, FalseClass, Object] # @return [Datatype::Boolean] def ==(other) falsey = other.kind_of?(False) || other.kind_of?(FalseClass) falsey ? True.instance : False.instance end # Check for inequality of a Lox False with another Lox object # @param other [Datatype::BuiltinDatatype, FalseClass, Object] # @return [Datatype::Boolean] def !=(other) falsey = other.kind_of?(False) || other.kind_of?(FalseClass) falsey ? False.instance : True.instance end end # class False.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/false.rb |