Fix style and logic issues in Ruby bindings