module PyCall::IRubyHelper

Private Instance Methods

check_python_object_respond_to_format_method(obj, method_name) click to toggle source
# File lib/pycall/iruby_helper.rb, line 8
def check_python_object_respond_to_format_method(obj, method_name)
  return false unless obj.kind_of? PyObjectWrapper
  return false unless obj.respond_to? method_name
  true
end
register_python_object_formatter(format_name, mime, priority_value=0) click to toggle source
# File lib/pycall/iruby_helper.rb, line 14
def register_python_object_formatter(format_name, mime, priority_value=0)
  method_name = :"_repr_#{format_name}_"
  match do |obj|
    check_python_object_respond_to_format_method(obj, method_name)
  end
  priority priority_value
  format mime, &method_name
end