Squirrel::Template::Expr::WrapScalar - provide methods for scalars
len = somescalar.length; upper = somescalar.upper; lower = somescalar.lower; defd = somescalar.defined; trimmed = somescalar.trim; split = somescalar.split; split = somescalar.split(":"); split = somescalar.split(":", count); formatted = somescalar.format("%05d"); value = somescalar.evaltag quoted = somescalar.quotemeta contains = somescalar.contains("foo") pos = somescalar.index("foo") pos = somescalar.index("foo", 5) pos = somescalar.rindex("foo") pos = somescalar.rindex("foo", 5) char = somenumber.chr int = somenumber.int random = somenumber.rand abs = (-10).abs # 10 floor = (-10.1).floor # -11 ceil = (-10.1).ceil # -10 somescalar.is_list # always false somescalar.is_hash # always false
Provides virtual methods for scalars in the Squirrel::Template manpage expressions.
Return the length of the string in characters.
Return the string in upper case
Return the string in lower case.
Return true if the string has a defined value.
Return a list object of the string split on the regular expression
sep
, returning up to count
objects. sep
defaults to " "
,
count
defaults to 0
. A count of 0
returns as many elements
as are found but removes any trailing empty length elements. A
negative count
returns all elements.
Evalulate the value of string as if processed as a tag. The string must not include the surrounding <: ... :>.
Return the string with regular expression metacharacters quoted with
\
.
Returns true if the subject contains the given substring.
Return the position of substring
within the subject, searching
forward from start
or from the beginning of the string. Returns -1
if substring
isn't found.
Return the position of substring
within the subject, searching
backward from start
or from the end of the string. Returns -1 if
substring
isn't found.
Replace the given regexp
in the string with replacement
. $1
etc are replaced with what the corresponding parenthesized expression
in the regexp matched. $$
is replaced with $
.
If global
is present and true, replace every instance.
Does not modify the source, simply returns the modified text.
Convert a character code into a character.
(65).chr # "A"
Convert a number to an integer.
(10.1).int # 10
Produce a floating point random number greater or equal to 0 and less than the subject.
(10).rand # 0 <= result < 10
Return the absolute value of the subject.
Return the highest integer less than or equal to the subject
(10).floor # 10 (10.1).floor # 10 (-10.1).floor # -11
Return the lowest integer greater than or equal to the subject.
(10).ceil # 10 (10.1).ceil # 11 (-10.1).ceil # -10
Test if this object is a list. Always true for a list.
Test if this object is a hash. Always false for a list.
Test if this object is a code object.
the Squirrel::Template::Expr manpage, the Squirrel::Template manpage
Tony Cook <tony@develop-help.com>