Class: Polars::BinaryExpr
- Inherits:
-
Object
- Object
- Polars::BinaryExpr
- Defined in:
- lib/polars/binary_expr.rb
Overview
Namespace for binary related expressions.
Instance Method Summary collapse
-
#contains(literal) ⇒ Expr
Check if binaries in Series contain a binary substring.
-
#decode(encoding, strict: true) ⇒ Expr
Decode a value using the provided encoding.
-
#encode(encoding) ⇒ Expr
Encode a value using the provided encoding.
-
#ends_with(suffix) ⇒ Expr
Check if string values end with a binary substring.
-
#reinterpret(dtype:, endianness: "little") ⇒ Expr
Interpret a buffer as a numerical Polars type.
-
#size(unit = "b") ⇒ Expr
Get the size of binary values in the given unit.
-
#starts_with(prefix) ⇒ Expr
Check if values start with a binary substring.
Instance Method Details
#contains(literal) ⇒ Expr
Check if binaries in Series contain a binary substring.
43 44 45 46 |
# File 'lib/polars/binary_expr.rb', line 43 def contains(literal) literal = Utils.parse_into_expression(literal, str_as_lit: true) Utils.wrap_expr(_rbexpr.binary_contains(literal)) end |
#decode(encoding, strict: true) ⇒ Expr
Decode a value using the provided encoding.
153 154 155 156 157 158 159 160 161 |
# File 'lib/polars/binary_expr.rb', line 153 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.
191 192 193 194 195 196 197 198 199 |
# File 'lib/polars/binary_expr.rb', line 191 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(suffix) ⇒ Expr
Check if string values end with a binary substring.
79 80 81 82 |
# File 'lib/polars/binary_expr.rb', line 79 def ends_with(suffix) suffix = Utils.parse_into_expression(suffix, str_as_lit: true) Utils.wrap_expr(_rbexpr.binary_ends_with(suffix)) end |
#reinterpret(dtype:, endianness: "little") ⇒ Expr
Interpret a buffer as a numerical Polars type.
257 258 259 260 261 262 263 264 265 266 |
# File 'lib/polars/binary_expr.rb', line 257 def reinterpret( dtype:, endianness: "little" ) dtype = Utils.parse_into_datatype_expr(dtype) Utils.wrap_expr( _rbexpr.bin_reinterpret(dtype._rbdatatype_expr, endianness) ) end |
#size(unit = "b") ⇒ Expr
Get the size of binary values in the given unit.
225 226 227 228 229 |
# File 'lib/polars/binary_expr.rb', line 225 def size(unit = "b") sz = Utils.wrap_expr(_rbexpr.bin_size_bytes) sz = Utils.scale_bytes(sz, to: unit) sz end |
#starts_with(prefix) ⇒ Expr
Check if values start with a binary substring.
117 118 119 120 |
# File 'lib/polars/binary_expr.rb', line 117 def starts_with(prefix) prefix = Utils.parse_into_expression(prefix, str_as_lit: true) Utils.wrap_expr(_rbexpr.binary_starts_with(prefix)) end |