struct Bindgen::Util::Tribool

Overview

A tribool can be in one of three states: true, false or .unset. Used in Configuration to distinguish an unset (for the default) value from an explicit false.

The user can also use an empty value in the configuration to explicitly use the default.

Use this type in a YAML.mapping like this:

my_option: {
  type: Util::Tribool,
  default: Util::Tribool.unset,
}

Defined in:

bindgen/util/tribool.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(ctx : YAML::ParseContext, node : YAML::Nodes::Node) #

[View source]
def self.new(value : Bool | Nil) #

[View source]

Class Method Detail

def self.unset #

Returns a new unset Tribool.


[View source]

Instance Method Detail

def ==(bool : Bool) #

Compares the value to bool. If this tribool is unset, this will never be true. See also #unset?, #true? and #false?


[View source]
def ==(tri : Tribool) #

Compares this to the other Tribool.


[View source]
def false?(default_value : Bool) : Bool #

Returns true only if this tri-bool is false, or if it is unset and the default_value is.


[View source]
def get(default_value : Bool) : Bool #

Returns the value as Bool. If this tri-bool is unset, returns the default_value. See also #true? and #false?.


[View source]
def true?(default_value : Bool) : Bool #

Returns true only if this tri-bool is true, or if it is unset and the default_value is. This is semantically a alias for #get.


[View source]
def unset? #

Returns true if this tribool is unset.


[View source]