Might be a bit simpler to do:

``` ruby
delegated_methods = [:lines, :eql?, :==, :encoding]
delegated_methods &= String.instance_methods
delegated_methods.each do |name|
  # your delegation logic from above
end
```

...then there's no need to special case `encoding`: my suggested logic takes care of only defining delegate methods for the things string responds to.