module Dusic::Misc

Extended Modules

Direct including types

Defined in:

dusic/misc.cr

Instance Method Summary

Instance Method Detail

def await(timeout : Time::Span = 10.seconds, interval : Time::Span = 250.milliseconds, &) : Bool #

Loops and calls provided block. Stops when timeout is hit (result will be false) or block returns truthy value (result will be true)


[View source]
def color(key : String) : UInt32 | Nil #

Return named color UInt32 which can be accepted by Discord


[View source]
def format_seconds(ts : Time::Span) : String #

Format time span in format of HH:MM:SS


[View source]
def format_seconds(seconds : Int32) : String #

[View source]
def ms_since(time : Time) : Float64 #

Return milliseconds since moment


[View source]
def run_gc #

Manually run GC and log some of it stats


[View source]
def spawn(name : String | Nil = nil, same_thread : Bool = false, &block) : Fiber #

Wrapper around default #spawn method

TODO Currently it seems to have no use. Consider deleting


[View source]
def t(key : String, options : Hash | NamedTuple | Nil = nil, force_locale = nil, count = nil, default = nil, iter = nil, &block : -> String) : String #

Wrapper over I18n.translate


[View source]
def t(*args, **opts) : String #

[View source]