{"id":17598936,"url":"https://github.com/almishkawi/binary","last_synced_at":"2026-04-19T10:31:26.030Z","repository":{"id":89210890,"uuid":"124119875","full_name":"almishkawi/binary","owner":"almishkawi","description":"Ruby gem to convert numbers into binaries and binaries into numbers","archived":false,"fork":false,"pushed_at":"2019-05-09T19:57:07.000Z","size":25,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-29T22:53:34.804Z","etag":null,"topics":["rails","ruby","rubygems"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/binary","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/almishkawi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-06T18:18:04.000Z","updated_at":"2019-11-24T14:07:31.000Z","dependencies_parsed_at":"2023-04-05T12:01:42.760Z","dependency_job_id":null,"html_url":"https://github.com/almishkawi/binary","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/almishkawi/binary","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/almishkawi%2Fbinary","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/almishkawi%2Fbinary/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/almishkawi%2Fbinary/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/almishkawi%2Fbinary/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/almishkawi","download_url":"https://codeload.github.com/almishkawi/binary/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/almishkawi%2Fbinary/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32003967,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"online","status_checked_at":"2026-04-19T02:00:07.110Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rails","ruby","rubygems"],"created_at":"2024-10-22T10:08:19.172Z","updated_at":"2026-04-19T10:31:25.622Z","avatar_url":"https://github.com/almishkawi.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Binary\n\nSimple Ruby gem to convert numbers into binaries \u0026 binaries into numbers\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'binary'\n```\n\nThen run:\n\n    $ bundle\n\nOr from the terminal:\n\n    $ gem install binary\n\n## Usage\n\n```ruby\nrequire 'binary'\n```\n\nNumber to binary:\n\n```ruby\nBinary.binary 2018\n\nOr\n\n2018.to_b\n```\n`Output: \"11111100010\"`.\n\nArray of numbers to binaries.\n```ruby\nBinary.binary([[7,9,11])\n\nOr\n\n[7,9,11].to_b\n```\n`Output: [\"111\", \"1001\", \"1011\"]`.\n\nBinary to number:\n```ruby\nBinary.number \"11111100010\"\n\nOr\n\n\"11111100010\".to_num\n```\n`Output: 2018`.\n\nArray of binaries to numbers:\n```ruby\nBinary.number([\"111\", \"1001\", \"1011\"])\n\nOr\n\n[\"111\", \"1001\", \"1011\"].to_num\n\n```\n`Output: [7,9,11]`.\n\nOther methods available:\n\n```ruby\n# count the number of bits in a number's binary\nBinary.bits_count 1000\n# number of bits in 1000.to_b (\"1111101000\")\n```\n`Output: 10`.\n\n```ruby\n# count the \"1\"s in a number's binary\nBinary.ones_count 1000\n# number of ones in 1000.to_b (\"1111101000\")\n```\n`Output: 6`.\n\n```ruby\n# count the \"0\"s in a number's binary\nBinary.zeros_count 1000\n# number of zeros in 1000.to_b (\"1111101000\")\n```\n`Output: 4`.\n\n```ruby\n# list of binaries of prime numbers from 2 to 25\nBinary.prime 25\n```\n`Output: [\"10\", \"11\", \"101\", \"111\", \"1011\", \"1101\", \"10001\", \"10011\", \"10111\"]`.\n\n```ruby\n# Binary representation of a random number between 1 and 100\nBinary.random 100\n```\n`Output: \"111\"`.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falmishkawi%2Fbinary","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falmishkawi%2Fbinary","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falmishkawi%2Fbinary/lists"}