module
Ktistec::Util
Extended Modules
Defined in:
framework/util.crInstance Method Summary
-
#distance_of_time_in_words(from_time : Time, to_time : Time = Time.utc)
Transforms the span of time between two different times into words.
-
#distance_of_time_in_words(distance : Time::Span)
Transforms the span of time between two different times into words.
-
#id
Generates a random, URL-safe identifier.
-
#pluralize(noun)
Pluralizes a singular noun.
-
#render_as_text(content)
Renders content as simple text.
-
#render_as_text_and_truncate(content : String, length : Int, *, ellipsis = "…")
Renders content as simple text and truncates to the given length.
-
#sanitize(content)
Cleans up the content we receive from others.
-
#to_sentence(array, *, words_connector = ", ", last_word_connector = " and ")
Converts the array of words to comma-separated sentence form where the last word is joined by a connector word (by default "and").
-
#wrap_link(str, include_scheme = false, length = 30, tag = :a)
Wraps a string in a link if it is a URL.
Instance Method Detail
Transforms the span of time between two different times into words.
Transforms the span of time between two different times into words.
Generates a random, URL-safe identifier.
64 bits should ensure it takes about 5 billion attempts to generate a collision.
Renders content as simple text and truncates to the given length.
Converts the array of words to comma-separated sentence form where the last word is joined by a connector word (by default "and").
Wraps a string in a link if it is a URL.
By default, matches the weird format used by Mastodon: https://github.com/mastodon/mastodon/blob/main/app/lib/text_formatter.rb