Class: Ruby::Rego::BooleanValue

Inherits:
Value
  • Object
show all
Defined in:
lib/ruby/rego/value.rb

Overview

Represents a boolean value.

Constant Summary collapse

TYPE_NAME =
"boolean"

Instance Attribute Summary

Attributes inherited from Value

#value

Instance Method Summary collapse

Methods inherited from Value

#==, #fetch_reference, from_ruby, #hash, #object_key, #to_ruby, #type_name, #undefined?

Constructor Details

#initialize(value) ⇒ BooleanValue

Create a boolean value.

Parameters:

  • value (Boolean)

    boolean value

Raises:

  • (ArgumentError)


167
168
169
170
171
172
# File 'lib/ruby/rego/value.rb', line 167

def initialize(value)
  klass = value.class
  raise ArgumentError, "Expected Boolean, got #{klass}" unless [TrueClass, FalseClass].include?(klass)

  super
end

Instance Method Details

#truthy?Boolean

Determine truthiness.

Returns:

  • (Boolean)


177
178
179
# File 'lib/ruby/rego/value.rb', line 177

def truthy?
  value
end