Class: Smith::Tool::ArgumentScalarSnapshot
- Inherits:
-
Object
- Object
- Smith::Tool::ArgumentScalarSnapshot
- Extended by:
- Dry::Initializer
- Defined in:
- lib/smith/tool/argument_scalar_snapshot.rb
Instance Method Summary collapse
Instance Method Details
#copy(value) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/smith/tool/argument_scalar_snapshot.rb', line 23 def copy(value) case value when String then copy_string(value) when Integer then copy_integer(value) when TrueClass, FalseClass, NilClass then count(value) when Float then copy_float(value) else raise Error, "tool arguments must contain JSON-compatible values" end end |
#copy_key(key) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/smith/tool/argument_scalar_snapshot.rb', line 34 def copy_key(key) raise Error, "tool argument object keys must be strings or symbols" unless string?(key) || symbol?(key) normalized = if string?(key) normalize_utf8(key) else normalize_utf8(Symbol.instance_method(:to_s).bind_call(key)) end byte_counter.call(normalized.bytesize) string?(key) ? normalized : key end |