{"action":"created","comment":{"url":"https://api.github.com/repos/sympy/symengine/pulls/comments/35175268","id":35175268,"diff_hunk":"@@ -16,15 +16,53 @@ VALUE cbasic_alloc(VALUE klass){\n }\n \n VALUE cbasic_binary_op(VALUE self, VALUE operand2, void (*cwfunc_ptr)(basic_struct*, const basic_struct*, const basic_struct*)){\n-    basic_struct *this, *cbasic_operand2, *cresult;\n+    basic_struct *this, *cbasic_operand2, *cresult, *num_basic, *den_basic;\n     VALUE result;\n \n     Data_Get_Struct(self, basic_struct, this);\n-    Data_Get_Struct(operand2, basic_struct, cbasic_operand2);\n+    VALUE Klass, new_operand2, num, den;\n+\n+    switch(TYPE(operand2)) {\n+        case T_FIXNUM:\n+            Klass = rb_path2class(\"SymEngine::Integer\");\n+            new_operand2 = cbasic_alloc(Klass);\n+            Data_Get_Struct(new_operand2, basic_struct, cbasic_operand2);\n+            integer_set_si(cbasic_operand2, FIX2LONG(operand2));\n+            break;\n+\n+        case T_BIGNUM:\n+            Klass = rb_path2class(\"SymEngine::Integer\");\n+            new_operand2 = cbasic_alloc(Klass);\n+            Data_Get_Struct(new_operand2, basic_struct, cbasic_operand2);\n+            integer_set_ui(cbasic_operand2, NUM2ULONG(operand2));\n+            break;\n+\n+        case T_RATIONAL:\n+            num = rb_funcall(operand2, rb_intern(\"numerator\"), 0, NULL);\n+            den = rb_funcall(operand2, rb_intern(\"denominator\"), 0, NULL);\n+\n+            num_basic = basic_new_heap();\n+            den_basic = basic_new_heap();\n+\n+            GET_SYMINTFROMVAL(num, num_basic);\n+            GET_SYMINTFROMVAL(den, den_basic);\n+\n+            Klass = rb_path2class(\"SymEngine::Rational\");\n+            new_operand2 = cbasic_alloc(Klass);\n+            Data_Get_Struct(new_operand2, basic_struct, cbasic_operand2);\n+            rational_set(cbasic_operand2, num_basic, den_basic);\n+\n+            basic_free_heap(num_basic);\n+            basic_free_heap(den_basic);\n+","path":"symengine/ruby/ext/symengine/ruby_basic.c","position":44,"original_position":44,"commit_id":"2bc29591f416b021846d44797c2cbcd849affd49","original_commit_id":"2bc29591f416b021846d44797c2cbcd849affd49","user":{"login":"isuruf","id":5234427,"avatar_url":"https://avatars.githubusercontent.com/u/5234427?v=3","gravatar_id":"","url":"https://api.github.com/users/isuruf","html_url":"https://github.com/isuruf","followers_url":"https://api.github.com/users/isuruf/followers","following_url":"https://api.github.com/users/isuruf/following{/other_user}","gists_url":"https://api.github.com/users/isuruf/gists{/gist_id}","starred_url":"https://api.github.com/users/isuruf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isuruf/subscriptions","organizations_url":"https://api.github.com/users/isuruf/orgs","repos_url":"https://api.github.com/users/isuruf/repos","events_url":"https://api.github.com/users/isuruf/events{/privacy}","received_events_url":"https://api.github.com/users/isuruf/received_events","type":"User","site_admin":false},"body":"`break;` is needed","created_at":"2015-07-22T02:08:10Z","updated_at":"2015-07-22T02:08:10Z","html_url":"https://github.com/sympy/symengine/pull/487#discussion_r35175268","pull_request_url":"https://api.github.com/repos/sympy/symengine/pulls/487","_links":{"self":{"href":"https://api.github.com/repos/sympy/symengine/pulls/comments/35175268"},"html":{"href":"https://github.com/sympy/symengine/pull/487#discussion_r35175268"},"pull_request":{"href":"https://api.github.com/repos/sympy/symengine/pulls/487"}}},"pull_request":{"url":"https://api.github.com/repos/sympy/symengine/pulls/487","id":38653410,"html_url":"https://github.com/sympy/symengine/pull/487","diff_url":"https://github.com/sympy/symengine/pull/487.diff","patch_url":"https://github.com/sympy/symengine/pull/487.patch","issue_url":"https://api.github.com/repos/sympy/symengine/issues/487","number":487,"state":"open","locked":false,"title":"[WIP] Support for Integer and Rational classes in Ruby wrappers","user":{"login":"abinashmeher999","id":6918379,"avatar_url":"https://avatars.githubusercontent.com/u/6918379?v=3","gravatar_id":"","url":"https://api.github.com/users/abinashmeher999","html_url":"https://github.com/abinashmeher999","followers_url":"https://api.github.com/users/abinashmeher999/followers","following_url":"https://api.github.com/users/abinashmeher999/following{/other_user}","gists_url":"https://api.github.com/users/abinashmeher999/gists{/gist_id}","starred_url":"https://api.github.com/users/abinashmeher999/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abinashmeher999/subscriptions","organizations_url":"https://api.github.com/users/abinashmeher999/orgs","repos_url":"https://api.github.com/users/abinashmeher999/repos","events_url":"https://api.github.com/users/abinashmeher999/events{/privacy}","received_events_url":"https://api.github.com/users/abinashmeher999/received_events","type":"User","site_admin":false},"body":"TODO:\r\n- [x] Create instance of `SymEngine::Integer`\r\n- [x] Create instance of `SymEngine::Rational`\r\n- [x] Identify Ruby Integer as SymEngine Integer when used with a Basic\r\n- [ ] Identify Ruby Rational as SymEngine Rational when used with a Basic","created_at":"2015-06-26T14:17:14Z","updated_at":"2015-07-22T02:08:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"51ed1c7c311907660031a80668cf550ee1ec5c9a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sympy/symengine/pulls/487/commits","review_comments_url":"https://api.github.com/repos/sympy/symengine/pulls/487/comments","review_comment_url":"https://api.github.com/repos/sympy/symengine/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sympy/symengine/issues/487/comments","statuses_url":"https://api.github.com/repos/sympy/symengine/statuses/2bc29591f416b021846d44797c2cbcd849affd49","head":{"label":"abinashmeher999:ruby_integer_rational","ref":"ruby_integer_rational","sha":"2bc29591f416b021846d44797c2cbcd849affd49","user":{"login":"abinashmeher999","id":6918379,"avatar_url":"https://avatars.githubusercontent.com/u/6918379?v=3","gravatar_id":"","url":"https://api.github.com/users/abinashmeher999","html_url":"https://github.com/abinashmeher999","followers_url":"https://api.github.com/users/abinashmeher999/followers","following_url":"https://api.github.com/users/abinashmeher999/following{/other_user}","gists_url":"https://api.github.com/users/abinashmeher999/gists{/gist_id}","starred_url":"https://api.github.com/users/abinashmeher999/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abinashmeher999/subscriptions","organizations_url":"https://api.github.com/users/abinashmeher999/orgs","repos_url":"https://api.github.com/users/abinashmeher999/repos","events_url":"https://api.github.com/users/abinashmeher999/events{/privacy}","received_events_url":"https://api.github.com/users/abinashmeher999/received_events","type":"User","site_admin":false},"repo":{"id":31778301,"name":"symengine","full_name":"abinashmeher999/symengine","owner":{"login":"abinashmeher999","id":6918379,"avatar_url":"https://avatars.githubusercontent.com/u/6918379?v=3","gravatar_id":"","url":"https://api.github.com/users/abinashmeher999","html_url":"https://github.com/abinashmeher999","followers_url":"https://api.github.com/users/abinashmeher999/followers","following_url":"https://api.github.com/users/abinashmeher999/following{/other_user}","gists_url":"https://api.github.com/users/abinashmeher999/gists{/gist_id}","starred_url":"https://api.github.com/users/abinashmeher999/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abinashmeher999/subscriptions","organizations_url":"https://api.github.com/users/abinashmeher999/orgs","repos_url":"https://api.github.com/users/abinashmeher999/repos","events_url":"https://api.github.com/users/abinashmeher999/events{/privacy}","received_events_url":"https://api.github.com/users/abinashmeher999/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/abinashmeher999/symengine","description":"Fast symbolic manipulation library, written in C++","fork":true,"url":"https://api.github.com/repos/abinashmeher999/symengine","forks_url":"https://api.github.com/repos/abinashmeher999/symengine/forks","keys_url":"https://api.github.com/repos/abinashmeher999/symengine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/abinashmeher999/symengine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/abinashmeher999/symengine/teams","hooks_url":"https://api.github.com/repos/abinashmeher999/symengine/hooks","issue_events_url":"https://api.github.com/repos/abinashmeher999/symengine/issues/events{/number}","events_url":"https://api.github.com/repos/abinashmeher999/symengine/events","assignees_url":"https://api.github.com/repos/abinashmeher999/symengine/assignees{/user}","branches_url":"https://api.github.com/repos/abinashmeher999/symengine/branches{/branch}","tags_url":"https://api.github.com/repos/abinashmeher999/symengine/tags","blobs_url":"https://api.github.com/repos/abinashmeher999/symengine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/abinashmeher999/symengine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/abinashmeher999/symengine/git/refs{/sha}","trees_url":"https://api.github.com/repos/abinashmeher999/symengine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/abinashmeher999/symengine/statuses/{sha}","languages_url":"https://api.github.com/repos/abinashmeher999/symengine/languages","stargazers_url":"https://api.github.com/repos/abinashmeher999/symengine/stargazers","contributors_url":"https://api.github.com/repos/abinashmeher999/symengine/contributors","subscribers_url":"https://api.github.com/repos/abinashmeher999/symengine/subscribers","subscription_url":"https://api.github.com/repos/abinashmeher999/symengine/subscription","commits_url":"https://api.github.com/repos/abinashmeher999/symengine/commits{/sha}","git_commits_url":"https://api.github.com/repos/abinashmeher999/symengine/git/commits{/sha}","comments_url":"https://api.github.com/repos/abinashmeher999/symengine/comments{/number}","issue_comment_url":"https://api.github.com/repos/abinashmeher999/symengine/issues/comments{/number}","contents_url":"https://api.github.com/repos/abinashmeher999/symengine/contents/{+path}","compare_url":"https://api.github.com/repos/abinashmeher999/symengine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/abinashmeher999/symengine/merges","archive_url":"https://api.github.com/repos/abinashmeher999/symengine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/abinashmeher999/symengine/downloads","issues_url":"https://api.github.com/repos/abinashmeher999/symengine/issues{/number}","pulls_url":"https://api.github.com/repos/abinashmeher999/symengine/pulls{/number}","milestones_url":"https://api.github.com/repos/abinashmeher999/symengine/milestones{/number}","notifications_url":"https://api.github.com/repos/abinashmeher999/symengine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/abinashmeher999/symengine/labels{/name}","releases_url":"https://api.github.com/repos/abinashmeher999/symengine/releases{/id}","created_at":"2015-03-06T16:32:24Z","updated_at":"2015-07-01T13:33:03Z","pushed_at":"2015-07-21T21:32:12Z","git_url":"git://github.com/abinashmeher999/symengine.git","ssh_url":"git@github.com:abinashmeher999/symengine.git","clone_url":"https://github.com/abinashmeher999/symengine.git","svn_url":"https://github.com/abinashmeher999/symengine","homepage":"http://sympy.org","size":3268,"stargazers_count":3,"watchers_count":3,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":3,"default_branch":"master"}},"base":{"label":"sympy:master","ref":"master","sha":"e5f5038d4e120d7e4bb17125ba3f3b56e3277c3c","user":{"login":"sympy","id":260832,"avatar_url":"https://avatars.githubusercontent.com/u/260832?v=3","gravatar_id":"","url":"https://api.github.com/users/sympy","html_url":"https://github.com/sympy","followers_url":"https://api.github.com/users/sympy/followers","following_url":"https://api.github.com/users/sympy/following{/other_user}","gists_url":"https://api.github.com/users/sympy/gists{/gist_id}","starred_url":"https://api.github.com/users/sympy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sympy/subscriptions","organizations_url":"https://api.github.com/users/sympy/orgs","repos_url":"https://api.github.com/users/sympy/repos","events_url":"https://api.github.com/users/sympy/events{/privacy}","received_events_url":"https://api.github.com/users/sympy/received_events","type":"Organization","site_admin":false},"repo":{"id":42376,"name":"symengine","full_name":"sympy/symengine","owner":{"login":"sympy","id":260832,"avatar_url":"https://avatars.githubusercontent.com/u/260832?v=3","gravatar_id":"","url":"https://api.github.com/users/sympy","html_url":"https://github.com/sympy","followers_url":"https://api.github.com/users/sympy/followers","following_url":"https://api.github.com/users/sympy/following{/other_user}","gists_url":"https://api.github.com/users/sympy/gists{/gist_id}","starred_url":"https://api.github.com/users/sympy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sympy/subscriptions","organizations_url":"https://api.github.com/users/sympy/orgs","repos_url":"https://api.github.com/users/sympy/repos","events_url":"https://api.github.com/users/sympy/events{/privacy}","received_events_url":"https://api.github.com/users/sympy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sympy/symengine","description":"SymEngine is a fast symbolic manipulation library, written in C++ (SymEngine was previously called CSymPy)","fork":false,"url":"https://api.github.com/repos/sympy/symengine","forks_url":"https://api.github.com/repos/sympy/symengine/forks","keys_url":"https://api.github.com/repos/sympy/symengine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sympy/symengine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sympy/symengine/teams","hooks_url":"https://api.github.com/repos/sympy/symengine/hooks","issue_events_url":"https://api.github.com/repos/sympy/symengine/issues/events{/number}","events_url":"https://api.github.com/repos/sympy/symengine/events","assignees_url":"https://api.github.com/repos/sympy/symengine/assignees{/user}","branches_url":"https://api.github.com/repos/sympy/symengine/branches{/branch}","tags_url":"https://api.github.com/repos/sympy/symengine/tags","blobs_url":"https://api.github.com/repos/sympy/symengine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sympy/symengine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sympy/symengine/git/refs{/sha}","trees_url":"https://api.github.com/repos/sympy/symengine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sympy/symengine/statuses/{sha}","languages_url":"https://api.github.com/repos/sympy/symengine/languages","stargazers_url":"https://api.github.com/repos/sympy/symengine/stargazers","contributors_url":"https://api.github.com/repos/sympy/symengine/contributors","subscribers_url":"https://api.github.com/repos/sympy/symengine/subscribers","subscription_url":"https://api.github.com/repos/sympy/symengine/subscription","commits_url":"https://api.github.com/repos/sympy/symengine/commits{/sha}","git_commits_url":"https://api.github.com/repos/sympy/symengine/git/commits{/sha}","comments_url":"https://api.github.com/repos/sympy/symengine/comments{/number}","issue_comment_url":"https://api.github.com/repos/sympy/symengine/issues/comments{/number}","contents_url":"https://api.github.com/repos/sympy/symengine/contents/{+path}","compare_url":"https://api.github.com/repos/sympy/symengine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sympy/symengine/merges","archive_url":"https://api.github.com/repos/sympy/symengine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sympy/symengine/downloads","issues_url":"https://api.github.com/repos/sympy/symengine/issues{/number}","pulls_url":"https://api.github.com/repos/sympy/symengine/pulls{/number}","milestones_url":"https://api.github.com/repos/sympy/symengine/milestones{/number}","notifications_url":"https://api.github.com/repos/sympy/symengine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sympy/symengine/labels{/name}","releases_url":"https://api.github.com/repos/sympy/symengine/releases{/id}","created_at":"2008-08-13T18:40:14Z","updated_at":"2015-07-22T01:52:50Z","pushed_at":"2015-07-21T21:32:12Z","git_url":"git://github.com/sympy/symengine.git","ssh_url":"git@github.com:sympy/symengine.git","clone_url":"https://github.com/sympy/symengine.git","svn_url":"https://github.com/sympy/symengine","homepage":"http://sympy.org","size":23022,"stargazers_count":71,"watchers_count":71,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":60,"mirror_url":null,"open_issues_count":87,"forks":60,"open_issues":87,"watchers":71,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sympy/symengine/pulls/487"},"html":{"href":"https://github.com/sympy/symengine/pull/487"},"issue":{"href":"https://api.github.com/repos/sympy/symengine/issues/487"},"comments":{"href":"https://api.github.com/repos/sympy/symengine/issues/487/comments"},"review_comments":{"href":"https://api.github.com/repos/sympy/symengine/pulls/487/comments"},"review_comment":{"href":"https://api.github.com/repos/sympy/symengine/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sympy/symengine/pulls/487/commits"},"statuses":{"href":"https://api.github.com/repos/sympy/symengine/statuses/2bc29591f416b021846d44797c2cbcd849affd49"}}}}