struct RemiLib::RSConf::RSScalar

Overview

RSScalar wraps a scalar value in RSConf. Scalar values are integers, floats, booleans, strings, or the null value.

Defined in:

remilib/rsconf/common.cr

Constructors

Instance Method Summary

Instance methods inherited from class Object

toRsconf(io : IO, *, indentSize : Int = 2, alwaysQuoteKeys : Bool = false, explicitRootObject : Bool = false, commaAfterValues : Bool = false, extraNewlineBetweenToplevelKeys : Bool = false) : Nil
toRsconf(*, indentSize : Int = 2, alwaysQuoteKeys : Bool = false, explicitRootObject : Bool = false, commaAfterValues : Bool = false, extraNewlineBetweenToplevelKeys : Bool = false) : String
toRsconf

Class methods inherited from class Object

fromRsconf(toplevel : RemiLib::RSConf::RSValue)
fromRsconf(data : String | IO | Path)
fromRsconf

Constructor Detail

def self.new(value : Int) #

Creates a new RSScalar instance. The value must fit into an RSInteger.


[View source]
def self.new(value : Float32 | Float64) #

Creates a new RSScalar instance. The value must fit into an RSInteger.


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

Creates a new RSScalar instance.


[View source]
def self.new(value : String) #

Creates a new RSScalar instance.


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

Creates a new RSScalar instance.


[View source]

Instance Method Detail

def bool : Bool #

Returns the scalar value that has the type Bool. If this instance does not hold the correct type, an exception is raised.


[View source]
def bool? : Bool | Nil #

Returns the scalar value that has the type Bool|Nil. If this instance does not hold the correct type, an exception is raised.


[View source]
def float : Float64 #

Returns the scalar value that has the type Float64. If this instance does not hold the correct type, an exception is raised.


[View source]
def float! : Float64 #

Returns the scalar value that has the type Float64. If this instance does not hold either an integer or float, an exception is raised. If this holds an integer, it is converted to Float64 using to_f64!.


[View source]
def float? : Float64 | Nil #

Returns the scalar value that has the type Float64|Nil. If this instance does not hold the correct type, an exception is raised.


[View source]
def int : RSInteger #

Returns the scalar value that has the type RSInteger. If this instance does not hold the correct type, an exception is raised.


[View source]
def int! : RSInteger #

Returns the scalar value that has the type RSInteger. If this instance does not hold either an integer or float, an exception is raised. If this holds a float, it is converted to RSInteger using to_128!.


[View source]
def int? : RSInteger | Nil #

Returns the scalar value that has the type RSInteger|Nil. If this instance does not hold the correct type, an exception is raised.


[View source]
def isBool? : Bool #

Returns true if this instance contains a scalar of the type Bool, or false otherwise.


[View source]
def isFloat? : Bool #

Returns true if this instance contains a scalar of the type Float64, or false otherwise.


[View source]
def isFloatable? : Bool #

Returns true if this scalar holds an integer or float value, or false otherwise.


[View source]
def isInt? : Bool #

Returns true if this instance contains a scalar of the type RSInteger, or false otherwise.


[View source]
def isIntable? : Bool #

Returns true if this scalar holds an integer or float value, or false otherwise.


[View source]
def isNil? : Bool #

Returns true if this scalar holds the null value, or false otherwise.


[View source]
def isString? : Bool #

Returns true if this instance contains a scalar of the type String, or false otherwise.


[View source]
def string : String #

Returns the scalar value that has the type String. If this instance does not hold the correct type, an exception is raised.


[View source]
def string! : String #

Returns this scalar value as a string. Non-string values will be converted to string using #to_s.


[View source]
def string? : String | Nil #

Returns the scalar value that has the type String|Nil. If this instance does not hold the correct type, an exception is raised.


[View source]
def toRsconf(builder : RemiLib::RSConf::Builder) #

Converts this instance to RSConf data by writing data using builder.


[View source]
def tryFloat : Float64 | Nil #

Attempts to return the scalar value that has the type Float64. If this instance does not hold a float, this returns nil.

This is not the same as a scalar that holds a float or a null value. For that, use #float?.


[View source]
def tryInt : RSInteger | Nil #

Attempts to return the scalar value that has the type RSInteger. If this instance does not hold either an integer, this returns nil.

This is not the same as a scalar that holds an integer or a null value. For that, use #int?.


[View source]
def val : RSInteger | Float64 | Bool | String | Nil #

Returns the value of this scalar.


[View source]