Class: Loxxy::Datatype::True

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

Overview

Class for representing a Lox true value.

Instance Attribute Summary

Attributes inherited from BuiltinDatatype

#value

Instance Method Summary collapse

Methods inherited from Boolean

#false?

Methods inherited from BuiltinDatatype

#!, #!=, #accept, #and, #falsey?, #or, #to_str, #truthy?

Constructor Details

#initializeTrue

Build the sole instance



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

def initialize
  super(true)
end

Instance Method Details

#==(other) ⇒ Datatype::Boolean

Check for equality of a Lox True with another Lox object / Ruby true

Parameters:

Returns:



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

def ==(other)
  thruthy = other.kind_of?(True) || other.kind_of?(TrueClass)
  thruthy ? True.instance : False.instance
end

#true?TrueClass

Is this object representing the true value in Lox?

Returns:

  • (TrueClass)


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

def true?
  true
end