Skip to content

Commit adb794b

Browse files
committed
Add StrValue.str_of
1 parent 4f93d5e commit adb794b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/spellbind/str_values.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ def derive_from_many(cls, transformer: Callable[[Iterable[str]], str], *values:
106106
is_associative=is_associative,
107107
)
108108

109+
@classmethod
110+
def str_of(cls, value: Any) -> StrValue:
111+
if isinstance(value, Value):
112+
return value.to_str()
113+
else:
114+
return StrConstant.of(str(value))
115+
109116

110117
def concatenate(*values: StrLike) -> StrValue:
111118
return StrValue.derive_from_many(_join_strs, *values, is_associative=True)

0 commit comments

Comments
 (0)