class SyntaxTree::YARV::AnyToString
~~~
“#{5}”
~~~ruby
### Usage
object’s ‘to_s` method does not return a string.
This is used in conjunction with `objtostring` as a fallback for when an
and then pushes that back on the stack.
Ruby’s built in string coercion to coerce the second value to a string
pushes it back on the stack. If the first value is not a string, it uses
It pops two values off the stack. If the first value is a string it
`anytostring` ensures that the value on top of the stack is a string.
### Summary
def ==(other)
def ==(other) other.is_a?(AnyToString) end
def call(vm)
def call(vm) original, value = vm.pop(2) if value.is_a?(String) vm.push(value) else vm.push("#<#{original.class.name}:0000>") end end
def deconstruct_keys(_keys)
def deconstruct_keys(_keys) {} end
def disasm(fmt)
def disasm(fmt) fmt.instruction("anytostring") end
def pops
def pops 2 end
def pushes
def pushes 1 end
def to_a(_iseq)
def to_a(_iseq) [:anytostring] end