Use when working with Ruby's standard library including Enumerable, File I/O, Time/Date, Regular Expressions, and core classes.
View on GitHubTheBushidoCollective/han
jutsu-ruby
January 24, 2026
Select agents to install to:
npx add-skill https://github.com/TheBushidoCollective/han/blob/main/jutsu/jutsu-ruby/skills/ruby-standard-library/SKILL.md -a claude-code --skill ruby-standard-libraryInstallation paths:
.claude/skills/ruby-standard-library/# Ruby Standard Library
Master Ruby's rich standard library. Ruby comes with powerful built-in classes and modules that handle common programming tasks elegantly.
## Enumerable
The Enumerable module provides iteration methods for collections.
### Common Enumerable Methods
```ruby
numbers = [1, 2, 3, 4, 5]
# map/collect - Transform elements
numbers.map { |n| n * 2 } # [2, 4, 6, 8, 10]
numbers.map(&:to_s) # ["1", "2", "3", "4", "5"]
# select/filter - Keep elements matching condition
numbers.select { |n| n.even? } # [2, 4]
numbers.filter(&:odd?) # [1, 3, 5]
# reject - Remove elements matching condition
numbers.reject { |n| n.even? } # [1, 3, 5]
# find/detect - First element matching condition
numbers.find { |n| n > 3 } # 4
# find_all - All elements matching condition (alias for select)
numbers.find_all { |n| n > 2 } # [3, 4, 5]
# reduce/inject - Accumulate values
numbers.reduce(0) { |sum, n| sum + n } # 15
numbers.reduce(:+) # 15
numbers.reduce(:*) # 120
# each - Iterate over elements
numbers.each { |n| puts n }
# each_with_index - Iterate with index
numbers.each_with_index { |n, i| puts "#{i}: #{n}" }
# each_with_object - Iterate with mutable object
numbers.each_with_object({}) { |n, hash| hash[n] = n * 2 }
# any? - True if any element matches
numbers.any? { |n| n > 4 } # true
numbers.any?(&:even?) # true
# all? - True if all elements match
numbers.all? { |n| n > 0 } # true
numbers.all?(&:even?) # false
# none? - True if no elements match
numbers.none? { |n| n < 0 } # true
# one? - True if exactly one element matches
numbers.one? { |n| n == 3 } # true
# partition - Split into two arrays [matching, non-matching]
evens, odds = numbers.partition(&:even?)
# group_by - Group elements by key
numbers.group_by { |n| n % 2 == 0 ? :even : :odd }
# => {:odd=>[1, 3, 5], :even=>[2, 4]}
# chunk - Group consecutive elements
[1, 2, 2, 3, 3, 3, 4].chunk(&:itself).to_a
# => [[1, [1]], [2, [2, 2]], [3, [3, 3, 3]], [4, [4]]]
#