struct Crinja::SafeString
- Crinja::SafeString
- Struct
- Value
- Object
Defined in:
runtime/safe_string.crConstant Summary
-
NIL =
plain(nil)
Constructors
-
.escape(value : Value) : SafeString
Escapes value and wraps it in a
SafeString
. - .new(string : String, plain_value : Bool = false)
Class Method Summary
- .build(&)
-
.escape(value : Nil)
Escapes value and wraps it in a
SafeString
. -
.escape(value : SafeString)
Escapes value and wraps it in a
SafeString
. -
.escape(value : Number)
Escapes value and wraps it in a
SafeString
. -
.escape(value : Array)
Escapes value and wraps it in a
SafeString
. -
.escape(value : Hash)
Escapes value and wraps it in a
SafeString
. -
.escape(string)
Escapes value and wraps it in a
SafeString
. -
.escape(&)
Yields a builder which automatically escapes.
-
.plain(value)
for literals such as numbers or booleans, will not be wrapped in quotes by inspect
Instance Method Summary
- #+(other : String | SafeString | Char)
-
#==(other)
Returns
true
if this struct is equal to other. - #[](index : Int)
- #[](*args)
- #[]?(*args)
- #each_line(chomp = true, &)
- #gsub(search, replace)
-
#inspect(io : IO)
Appends this struct's name and instance variables names and values to the given IO.
- #lstrip(*args)
- #partition(sep)
- #rpartition(sep)
- #rstrip(*args)
- #size(*args, **options)
- #size(*args, **options, &)
- #strip(*args)
- #sub(search, replace)
- #sub(search, &)
- #to_f(*args, **options)
- #to_f(*args, **options, &)
- #to_i(*args, **options)
- #to_i(*args, **options, &)
- #to_json(*args, **options)
- #to_json(*args, **options, &)
- #to_s(*args, **options)
- #to_s(*args, **options, &)
Constructor Detail
Escapes value and wraps it in a SafeString
.
Class Method Detail
for literals such as numbers or booleans, will not be wrapped in quotes by inspect
Instance Method Detail
Returns true
if this struct is equal to other.
Both structs' instance vars are compared to each other. Thus, two structs are considered equal if each of their instance variables are equal. Subclasses should override this method to provide specific equality semantics.
struct Point
def initialize(@x : Int32, @y : Int32)
end
end
p1 = Point.new 1, 2
p2 = Point.new 1, 2
p3 = Point.new 3, 4
p1 == p2 # => true
p1 == p3 # => false
Appends this struct's name and instance variables names and values to the given IO.
struct Point
def initialize(@x : Int32, @y : Int32)
end
end
p1 = Point.new 1, 2
p1.to_s # "Point(@x=1, @y=2)"
p1.inspect # "Point(@x=1, @y=2)"