Class: Loxxy::Datatype::False

Inherits:
Boolean show all
Includes:
Singleton
Defined in:
lib/loxxy/datatype/false.rb

Overview

Class for representing a Lox false value.

Instance Attribute Summary

Attributes inherited from BuiltinDatatype

#value

Instance Method Summary collapse

Methods inherited from Boolean

#true?

Methods inherited from BuiltinDatatype

#!, #!=, #accept, #and, #or, #to_str

Constructor Details

#initializeFalse

Build the sole instance



13
14
15
# File 'lib/loxxy/datatype/false.rb', line 13

def initialize
  super(false)
end

Instance Method Details

#==(other) ⇒ Datatype::Boolean

Check for equality of a Lox False with another Lox object

Parameters:

Returns:



40
41
42
43
# File 'lib/loxxy/datatype/false.rb', line 40

def ==(other)
  falsey = other.kind_of?(False) || other.kind_of?(FalseClass)
  falsey ? True.instance : False.instance
end

#false?TrueClass

Is this object representing a false value in Lox?

Returns:

  • (TrueClass)


19
20
21
# File 'lib/loxxy/datatype/false.rb', line 19

def false?
  true
end

#falsey?Boolean

Is the value considered falsey in Lox? Rule: false and nil are falsey and everything else is truthy. This test used in conditional statements (i.e. if, while)

Returns:



26
27
28
# File 'lib/loxxy/datatype/false.rb', line 26

def falsey?
  true
end

#truthy?Boolean

Is the value considered truthy in Lox? Rule: false and nil are falsey and everything else is truthy. This test used in conditional statements (i.e. if, while)

Returns:



33
34
35
# File 'lib/loxxy/datatype/false.rb', line 33

def truthy?
  false
end