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.


def self.new(string : String, plain_value : Bool = false) #

Class Method Detail

def self.build(&) #

def self.escape(value : Nil) #

Escapes value and wraps it in a SafeString.


def self.escape(value : SafeString) #

Escapes value and wraps it in a SafeString.


def self.escape(value : Number) #

Escapes value and wraps it in a SafeString.


def self.escape(value : Array) #

Escapes value and wraps it in a SafeString.


def self.escape(value : Hash) #

Escapes value and wraps it in a SafeString.


def self.escape(string) #

Escapes value and wraps it in a SafeString.


def self.escape(&) #

Yields a builder which automatically escapes.

TODO Implement stream IO.


def self.plain(value) #

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


Instance Method Detail

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

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

def [](index : Int) #

def [](*args) #

def []?(*args) #

def each_line(chomp = true, &) #

def gsub(search, replace) #

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

def lstrip(*args) #

def partition(sep) #

def rpartition(sep) #

def rstrip(*args) #

def size(*args, **options) #

def size(*args, **options, &) #

def strip(*args) #

def sub(search, replace) #

def sub(search, &) #

def to_f(*args, **options) #

def to_f(*args, **options, &) #

def to_i(*args, **options) #

def to_i(*args, **options, &) #

def to_json(*args, **options) #

def to_json(*args, **options, &) #

def to_s(*args, **options) #

def to_s(*args, **options, &) #