struct Crinja::SafeString

Defined in:

runtime/safe_string.cr

Constant Summary

NIL = plain(nil)

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.escape(value : Value) : SafeString #

Escapes value and wraps it in a SafeString.


[View source]
def self.new(string : String, plain_value : Bool = false) #

[View source]

Class Method Detail

def self.build(&) #

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

Escapes value and wraps it in a SafeString.


[View source]
def self.escape(value : SafeString) #

Escapes value and wraps it in a SafeString.


[View source]
def self.escape(value : Number) #

Escapes value and wraps it in a SafeString.


[View source]
def self.escape(value : Array) #

Escapes value and wraps it in a SafeString.


[View source]
def self.escape(value : Hash) #

Escapes value and wraps it in a SafeString.


[View source]
def self.escape(string) #

Escapes value and wraps it in a SafeString.


[View source]
def self.escape(&) #

Yields a builder which automatically escapes.

TODO Implement stream IO.


[View source]
def self.plain(value) #

for literals such as numbers or booleans, will not be wrapped in quotes by inspect


[View source]

Instance Method Detail

def +(other : String | SafeString | Char) #

[View source]
def ==(other) #
Description copied from struct Struct

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

[View source]
def [](index : Int) #

[View source]
def [](*args) #

[View source]
def []?(*args) #

[View source]
def each_line(chomp = true, &) #

[View source]
def gsub(search, replace) #

[View source]
def inspect(io : IO) #
Description copied from struct Struct

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)"

[View source]
def lstrip(*args) #

[View source]
def partition(sep) #

[View source]
def rpartition(sep) #

[View source]
def rstrip(*args) #

[View source]
def size(*args, **options) #

[View source]
def size(*args, **options, &) #

[View source]
def strip(*args) #

[View source]
def sub(search, replace) #

[View source]
def sub(search, &) #

[View source]
def to_f(*args, **options) #

[View source]
def to_f(*args, **options, &) #

[View source]
def to_i(*args, **options) #

[View source]
def to_i(*args, **options, &) #

[View source]
def to_json(*args, **options) #

[View source]
def to_json(*args, **options, &) #

[View source]
def to_s(*args, **options) #

[View source]
def to_s(*args, **options, &) #

[View source]