Class: Polars::BinaryExpr

Inherits:
Object
  • Object
show all
Defined in:
lib/polars/binary_expr.rb

Overview

Namespace for binary related expressions.

Instance Method Summary collapse

Instance Method Details

#contains(lit) ⇒ Expr

Check if binaries in Series contain a binary substring.

Parameters:

  • lit (String)

    The binary substring to look for

Returns:



18
19
20
# File 'lib/polars/binary_expr.rb', line 18

def contains(lit)
  Utils.wrap_expr(_rbexpr.binary_contains(lit))
end

#decode(encoding, strict: true) ⇒ Expr

Decode a value using the provided encoding.

Parameters:

  • encoding ("hex", "base64")

    The encoding to use.

  • strict (Boolean) (defaults to: true)

    Raise an error if the underlying value cannot be decoded, otherwise mask out with a null value.

Returns:



51
52
53
54
55
56
57
58
59
# File 'lib/polars/binary_expr.rb', line 51

def decode(encoding, strict: true)
  if encoding == "hex"
    Utils.wrap_expr(_rbexpr.binary_hex_decode(strict))
  elsif encoding == "base64"
    Utils.wrap_expr(_rbexpr.binary_base64_decode(strict))
  else
    raise ArgumentError, "encoding must be one of {{'hex', 'base64'}}, got #{encoding}"
  end
end

#encode(encoding) ⇒ Expr

Encode a value using the provided encoding.

Parameters:

  • encoding ("hex", "base64")

    The encoding to use.

Returns:



67
68
69
70
71
72
73
74
75
# File 'lib/polars/binary_expr.rb', line 67

def encode(encoding)
  if encoding == "hex"
    Utils.wrap_expr(_rbexpr.binary_hex_encode)
  elsif encoding == "base64"
    Utils.wrap_expr(_rbexpr.binary_base64_encode)
  else
    raise ArgumentError, "encoding must be one of {{'hex', 'base64'}}, got #{encoding}"
  end
end

#ends_with(sub) ⇒ Expr

Check if string values end with a binary substring.

Parameters:

  • sub (String)

    Suffix substring.

Returns:



28
29
30
# File 'lib/polars/binary_expr.rb', line 28

def ends_with(sub)
  Utils.wrap_expr(_rbexpr.binary_ends_with(sub))
end

#starts_with(sub) ⇒ Expr

Check if values start with a binary substring.

Parameters:

  • sub (String)

    Prefix substring.

Returns:



38
39
40
# File 'lib/polars/binary_expr.rb', line 38

def starts_with(sub)
  Utils.wrap_expr(_rbexpr.binary_starts_with(sub))
end