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

#==, #canonical, canonicalize, canonicalize_each, canonicalize_float, #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)


224
225
226
227
228
229
# File 'lib/ruby/rego/value.rb', line 224

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)


234
235
236
# File 'lib/ruby/rego/value.rb', line 234

def truthy?
  value
end