Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

ruby-standard-library

БесплатноБез исполняемых скриптовНе проверен

Use when working with Ruby's standard library including Enumerable, File I/O, Time/Date, Regular Expressions, and core classes.

TheBushidoCollectiveот TheBushidoCollective★ 202 звезды на GitHub

Об этом скилле

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

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]]]

# take - First n elements
numbers.take(3)  # [1, 2, 3]

# drop - Skip first n elements
numbers.drop(3)  # [4, 5]

# take_while - Elements until condition fails
numbers.take_while { |n| n < 4 }  # [1, 2, 3]

# drop_while - Skip elements until condition fails
numbers.drop_while { |n| n < 4 }  # [4, 5]

# zip - Combine arrays
[1, 2, 3].zip(['a', 'b', 'c'])  # [[1, "a"], [2, "b"], [3, "c"]]

# min, max
numbers.min  # 1
numbers.max  # 5
numbers.minmax  # [1, 5]

# sort
[3, 1, 4, 1, 5].sort  # [1, 1, 3, 4, 5]
['cat', 'dog', 'bird'].sort_by(&:length)

# uniq - Remove duplicates
[1, 2, 2, 3, 3, 3].uniq  # [1, 2, 3]

# compact - Remove nil values
[1, nil, 2, nil, 3].compact  # [1, 2, 3]

# flat_map - Map and flatten
[[1, 2], [3, 4]].flat_map { |arr| arr.map { |n| n * 2 } }  # [2, 4, 6, 8]

# tally - Count occurrences
['a', 'b', 'a', 'c', 'b', 'a'].tally  # {"a"=>3, "b"=>2, "c"=>1}

Arrays

# Creation
arr = [1, 2, 3]
arr = Array.new(3, 0)  # [0, 0, 0]
arr = Array.new(3) { |i| i * 2 }  # [0, 2, 4]

# Access
arr[0]        # First element
arr[-1]       # Last element
arr[1..3]     # Range
arr.first     # 1
arr.last      # 3
arr.at(1)     # 2

# Modification
arr << 4              # Append
arr.push(5)           # Append
arr.unshift(0)        # Prepend
arr.pop               # Remove and return last
arr.shift             # Remove and return first
arr.delete_at(1)      # Delete at index
arr.delete(3)         # Delete value
arr.insert(1, 'a')    # Insert at index

# Combination
[1, 2] + [3, 4]       # [1, 2, 3, 4]
[1, 2] * 2            # [1, 2, 1, 2]
[1, 2, 3] - [2]       # [1, 3]
[1, 2] & [2, 3]       # [2] (intersection)
[1, 2] | [2, 3]       # [1, 2, 3] (union)

# Query
arr.include?(2)       # true
arr.empty?            # false
arr.length            # 3
arr.count             # 3
arr.count(2)          # Count occurrences

# Transformation
arr.reverse           # [3, 2, 1]
arr.flatten           # Flatten nested arrays
arr.compact           # Remove nils
arr.uniq              # Remove duplicates
arr.join(', ')        # Convert to string
arr.sample            # Random element
arr.shuffle           # Random order

Hashes

# Creation
hash = { name: 'Alice', age: 30 }
hash = Hash.new(0)  # Default value 0
hash = Hash.new { |h, k| h[k] = [] }  # Default block

# Access
hash[:name]           # 'Alice'
hash.fetch(:age)      # 30
hash.fetch(:email, 'N/A')  # With default
hash.dig(:person, :name)   # Safe nested access

# Modification
hash[:email] = '[email protected]'
hash.delete(:age)
hash.merge!(other_hash)
hash.transform_keys(&:to_s)
hash.transform_values { |v| v.to_s }

# Iteration
hash.each { |key, value| puts "#{key}: #{value}" }
hash.each_key { |key| puts key }
hash.each_value { |value| puts value }

# Query
hash.key?(:name)      # true
hash.value?('Alice')  # true
hash.empty?           # false
hash.size             # 2

# Transformation
hash.keys             # [:name, :age]
hash.values           # ['Alice', 30]
hash.invert           # S
Полный SKILL.md на GitHub

Установить ruby-standard-library в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Bash
Read
Write
Edit

FAQ

Что делает скилл ruby-standard-library?

Use when working with Ruby's standard library including Enumerable, File I/O, Time/Date, Regular Expressions, and core classes.

Как установить скилл ruby-standard-library?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл ruby-standard-library запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить ruby-standard-library с