I have some object that I'd like to compare with string. I'd like to know what method should I implement in order conversion of my object happens automatically when used as an argument to comparison operator.
line == '2 hello world'
You need to override your class'
class MyClass def ==(other) # custom equal comparison logic here # if you just need string comparison to_s == other end end