{"id":28312280,"url":"https://github.com/insomnius/rb","last_synced_at":"2026-02-11T19:31:22.273Z","repository":{"id":265038579,"uuid":"894937231","full_name":"insomnius/rb","owner":"insomnius","description":"rb is a Go library inspired by Ruby's expressive simplicity, bringing familiar methods like downcase, upcase, and count to the Go ecosystem. Perfect for Rubyists exploring Go or Gophers craving Ruby-style utility, rb combines Ruby-like elegance with Go's performance and safety.","archived":false,"fork":false,"pushed_at":"2025-08-16T11:38:03.000Z","size":43,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-16T13:43:46.271Z","etag":null,"topics":["golang","ruby"],"latest_commit_sha":null,"homepage":"","language":"Go","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/insomnius.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2024-11-27T09:16:57.000Z","updated_at":"2025-01-09T14:03:46.000Z","dependencies_parsed_at":"2025-08-16T13:33:33.767Z","dependency_job_id":null,"html_url":"https://github.com/insomnius/rb","commit_stats":null,"previous_names":["insomnius/ruby","insomnius/rb"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/insomnius/rb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insomnius%2Frb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insomnius%2Frb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insomnius%2Frb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insomnius%2Frb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/insomnius","download_url":"https://codeload.github.com/insomnius/rb/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insomnius%2Frb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29342086,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-11T18:58:20.535Z","status":"ssl_error","status_checked_at":"2026-02-11T18:56:44.814Z","response_time":97,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["golang","ruby"],"created_at":"2025-05-24T17:09:32.390Z","updated_at":"2026-02-11T19:31:22.267Z","avatar_url":"https://github.com/insomnius.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rb: Ruby-Like Elegance in Go\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/insomnius/rb)](https://goreportcard.com/report/github.com/insomnius/rb)\n[![Go Coverage](https://codecov.io/gh/insomnius/rb/branch/main/graph/badge.svg)](https://codecov.io/gh/insomnius/rb)\n[![Go Lint](https://golangci.com/badges/github.com/insomnius/rb.svg)](https://golangci.com/r/github.com/insomnius/rb)\n\nWelcome to `rb`, where the simplicity and elegance of Ruby meet the performance and robustness of Go. If you're a Rubyist curious about Go, or a Gopher longing for Ruby's expressive methods, this library bridges the gap by bringing Ruby-inspired utility methods to Go's strong typing and concurrency capabilities.\n\n## Why rb?\n- **Ruby Simplicity:** Experience Ruby-style methods like `downcase`, `upcase`, `chars`, and `count` in your Go projects.\n- **Go Power:** Maintain the speed and safety of Go while leveraging the expressive power of Ruby-like syntax.\n- **Familiarity:** Ideal for Ruby developers transitioning to Go or Go developers seeking more expressive tools.\n\n## Features\n- Ruby-inspired `String`, `Integer`, `Float`, `Boolean`, `Array`, `Hash`, and `Range` types.\n- Comprehensive method coverage including `map`, `select`, `reject`, `find`, `any`, `all`, `none`, and more.\n- Seamless integration into your Go projects with idiomatic Go practices.\n\n## Ruby-like Idiomatic Changes\n\nIn `rb-go`, the following Ruby-like method semantics have been adapted to Go's idiomatic patterns:\n\n- `!` → **`Enforce`**: Methods with Ruby's \"bang\" `!` suffix are now implemented with `Enforce`.\n  Example:\n  ```go\n  str.EnforceDowncase()\n  ```\n\n- `?` → **`Is`**: Methods with Ruby's \"question\" `?` suffix are now implemented with `Is`.\n  Example:\n  ```go\n  5.IsOdd()\n  ```\n\nThese changes ensure alignment with Go's naming conventions while maintaining Ruby's expressiveness.\n\n## Installation\n\n```bash\ngo get github.com/insomnius/rb\n```\n\n## Quick Start\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/insomnius/rb\"\n)\n\nfunc main() {\n\t// Working with rb.String\n\tstr := rb.String(\"Hello, World!\")\n\tfmt.Println(\"Original:\", str)             // Original: Hello, World!\n\tfmt.Println(\"Downcased:\", str.Downcase()) // Downcased: hello, world!\n\tfmt.Println(\"Capitalized:\", str.Capitalize()) // Capitalized: Hello, world!\n\tfmt.Println(\"Reversed:\", str.Reverse())   // Reversed: !dlroW ,olleH\n\n\tstr.EnforceDowncase()\n\tfmt.Println(\"Enforce Downcase:\", str) // Enforce Downcase: hello, world!\n\n\t// Ruby-style Array methods\n\tarr := rb.Array[rb.String]{\"ruby\", \"go\", \"ruby\", \"python\"}\n\tfmt.Println(\"Total Elements:\", arr.Count())     // Total Elements: 4\n\tfmt.Println(\"Count 'ruby':\", arr.Count(\"ruby\")) // Count 'ruby': 2\n\tfmt.Println(\"Count with Predicate:\", arr.Count(func(s rb.String) bool {\n\t\treturn s.Length() \u003e 2\n\t})) // Count with Predicate: 4\n\n\t// Array transformations\n\tmapped := arr.Map(func(s rb.String) rb.String {\n\t\treturn s.Upcase()\n\t})\n\tfmt.Println(\"Mapped:\", mapped) // Mapped: [RUBY GO RUBY PYTHON]\n\n\tselected := arr.Select(func(s rb.String) bool {\n\t\treturn s.Length() \u003e 3\n\t})\n\tfmt.Println(\"Selected:\", selected) // Selected: [ruby ruby python]\n\n\t// Working with rb.Integer\n\tnum := rb.Integer(5)\n\tfmt.Println(\"Is Prime:\", num.IsPrime())        // Is Prime: true\n\tfmt.Println(\"Factorial:\", num.Factorial())     // Factorial: 120\n\tfmt.Println(\"Divisors:\", num.Divisors())       // Divisors: [1 5]\n\n\t// Integer iteration\n\tnum.Times(func(i rb.Integer) {\n\t\tfmt.Printf(\"Count: %d\\n\", i)\n\t})\n\n\t// Working with rb.Float\n\tpi := rb.Float(3.14159)\n\tfmt.Println(\"Ceiled:\", pi.Ceil())    // Ceiled: 4\n\tfmt.Println(\"Floored:\", pi.Floor())  // Floored: 3\n\tfmt.Println(\"Rounded:\", pi.Round())  // Rounded: 3\n\n\t// Working with rb.Boolean\n\tflag := rb.Boolean(true)\n\tflag.IfTrue(func() { fmt.Println(\"It's true!\") })\n\tresult := flag.Ternary(\"yes\", \"no\")\n\tfmt.Println(\"Ternary result:\", result) // Ternary result: yes\n\n\t// Working with rb.Hash\n\thash := rb.Hash[rb.String, rb.Integer]{\"a\": 1, \"b\": 2, \"c\": 3}\n\tfmt.Println(\"Keys:\", hash.Keys())           // Keys: [a b c]\n\tfmt.Println(\"Values:\", hash.Values())       // Values: [1 2 3]\n\tfmt.Println(\"Has key 'a':\", hash.HasKey(\"a\")) // Has key 'a': true\n\n\t// Working with rb.Range\n\trng := rb.NewRange(rb.Integer(1), rb.Integer(5))\n\tfmt.Println(\"Range size:\", rng.Size())      // Range size: 5\n\tfmt.Println(\"Includes 3:\", rng.Include(3)) // Includes 3: true\n}\n```\n\n## Available Types\n\nThe library provides the following Ruby-inspired types:\n\n- **`rb.String`** - String manipulation and query methods\n- **`rb.Integer`** - Mathematical operations and iteration\n- **`rb.Float`** - Mathematical functions and rounding\n- **`rb.Boolean`** - Logical operations and conditional execution\n- **`rb.Array[T]`** - Collection methods and transformations\n- **`rb.Hash[K, V]`** - Key-value operations and iteration\n- **`rb.Range[T]`** - Range iteration and query methods\n\nEach type provides a comprehensive set of methods that mirror Ruby's functionality while maintaining Go's type safety and performance characteristics.\n\n## Documentation\nExplore the complete documentation and examples [here](https://pkg.go.dev/github.com/insomnius/rb).\n\n## Contributing\nWe welcome contributions from the community! Feel free to submit issues, fork the repository, and open pull requests.\n\n## License\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finsomnius%2Frb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finsomnius%2Frb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finsomnius%2Frb/lists"}