Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问clear审计通过

ruby-standard-libraryRuby standard library 搜索

Agent Skill

ruby-standard-library 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

396

周安装

17

GitHub Stars

142

下载量

139
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:ruby-standard-library(Ruby standard library 搜索)
来源仓库:https://github.com/thebushidocollective/han
仓库路径:skills/ruby-standard-library
安装命令:
npx skills add https://github.com/thebushidocollective/han --skill ruby-standard-library
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/thebushidocollective/han --skill ruby-standard-library

简介

用于查找、检索和筛选 Ruby 标准库相关技术信息。

  • 适合在开发环境中快速获取标准库使用方法和示例。
  • 通过 GitHub 仓库安装,使用 npx skills add 命令添加技能。
  • 建议确认仓库内容的权威性和更新状态。ruby-standard-library 属于研究检索类 Skill,可作为该场景下的辅助能力补充。
  • 使用时需注意版本兼容性和具体应用场景。

SKILL.md

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] = 'alice@example.com'
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           # Swap keys and values
hash.select { |k, v| v.is_a?(String) }
hash.reject { |k, v| v.nil? }
hash.compact          # Remove nil values
hash.slice(:name, :age)  # Extract subset

Strings

str = "Hello, World!"

# Case
str.upcase            # "HELLO, WORLD!"
str.downcase          # "hello, world!"
str.capitalize        # "Hello, world!"
str.swapcase          # "hELLO, wORLD!"
str.titleize          # Requires ActiveSupport

# Trimming
"  hello  ".strip    # "hello"
"  hello  ".lstrip   # "hello  "
"  hello  ".rstrip   # "  hello"

# Searching
str.include?("World")    # true
str.start_with?("Hello") # true
str.end_with?("!")       # true
str.index("World")       # 7
str.rindex("o")          # 8

# Splitting and joining
"a,b,c".split(",")       # ["a", "b", "c"]
["a", "b", "c"].join("-")  # "a-b-c"

# Replacement
str.sub("World", "Ruby")    # Replace first
str.gsub("o", "0")          # Replace all
str.delete("l")             # Remove characters
str.tr("aeiou", "12345")    # Translate characters

# Substring
str[0]                # "H"
str[0..4]             # "Hello"
str[7..]              # "World!"
str.slice(0, 5)       # "Hello"

# Query
str.empty?            # false
str.length            # 13
str.size              # 13
str.count("l")        # 3

# Conversion
"123".to_i            # 123
"3.14".to_f           # 3.14
:symbol.to_s          # "symbol"

# Encoding
str.encoding          # #<Encoding:UTF-8>
str.force_encoding("ASCII")
str.encode("ISO-8859-1")

# Multiline
text = <<~HEREDOC
  This is a
  multiline string
  with indentation removed
HEREDOC

Regular Expressions

# Creation
regex = /pattern/
regex = Regexp.new("pattern")

# Matching
"hello" =~ /ll/               # 2 (index)
"hello" !~ /zz/               # true
"hello".match(/l+/)           # #<MatchData "ll">
"hello".match?(/l+/)          # true (faster, no MatchData)

# Match data
match = "hello123".match(/(\w+)(\d+)/)
match[0]                      # "hello123" (full match)
match[1]                      # "hello" (first group)
match[2]                      # "123" (second group)

# Named captures
match = "hello123".match(/(?<word>\w+)(?<num>\d+)/)
match[:word]                  # "hello"
match[:num]                   # "123"

# String methods with regex
"hello world".scan(/\w+/)     # ["hello", "world"]
"a1b2c3".scan(/\d/)           # ["1", "2", "3"]

"hello".sub(/l/, 'L')         # "heLlo"
"hello".gsub(/l/, 'L')        # "heLLo"

"a:b:c".split(/:/)            # ["a", "b", "c"]

# Flags
/pattern/i                    # Case insensitive
/pattern/m                    # Multiline
/pattern/x                    # Extended (ignore whitespace)

# Common patterns
/\d+/                         # One or more digits
/\w+/                         # One or more word characters
/\s+/                         # One or more whitespace
/^start/                      # Start of string
/end$/                        # End of string
/[aeiou]/                     # Character class
/[^aeiou]/                    # Negated class
/(cat|dog)/                   # Alternation

File I/O

# Reading
content = File.read("file.txt")
lines = File.readlines("file.txt")

File.open("file.txt", "r") do |file|
  file.each_line do |line|
    puts line
  end
end

# Writing
File.write("file.txt", "content")

File.open("file.txt", "w") do |file|
  file.puts "line 1"
  file.puts "line 2"
end

# Appending
File.open("file.txt", "a") do |file|
  file.puts "appended line"
end

# File modes
# "r"  - Read only
# "w"  - Write (truncate)
# "a"  - Append
# "r+" - Read and write
# "w+" - Read and write (truncate)
# "a+" - Read and append

# File operations
File.exist?("file.txt")       # true/false
File.file?("file.txt")        # Is it a file?
File.directory?("dir")        # Is it a directory?
File.size("file.txt")         # Size in bytes
File.mtime("file.txt")        # Modification time
File.basename("/path/to/file.txt")  # "file.txt"
File.dirname("/path/to/file.txt")   # "/path/to"
File.extname("file.txt")      # ".txt"
File.join("path", "to", "file.txt")  # "path/to/file.txt"

# Directory operations
Dir.entries(".")              # List directory
Dir.glob("*.rb")              # Pattern matching
Dir.glob("**/*.rb")           # Recursive

Dir.mkdir("new_dir")
Dir.rmdir("old_dir")
Dir.pwd                       # Current directory
Dir.chdir("/path")            # Change directory

FileUtils.mkdir_p("a/b/c")    # Create nested dirs
FileUtils.rm_rf("dir")        # Remove recursively
FileUtils.cp("src", "dest")   # Copy file
FileUtils.mv("src", "dest")   # Move file

Time and Date

require 'time'
require 'date'

# Time
now = Time.now
utc = Time.now.utc
local = Time.now.localtime

# Components
now.year              # 2024
now.month             # 11
now.day               # 25
now.hour              # 14
now.min               # 30
now.sec               # 45
now.wday              # Day of week (0=Sunday)

# Creation
Time.new(2024, 11, 25, 14, 30, 45)
Time.parse("2024-11-25 14:30:45")
Time.at(1700000000)   # From Unix timestamp

# Formatting
now.strftime("%Y-%m-%d %H:%M:%S")
now.strftime("%B %d, %Y")          # November 25, 2024
now.iso8601                        # ISO 8601 format

# Arithmetic
now + 3600            # Add 1 hour (in seconds)
now - 86400           # Subtract 1 day
time2 - time1         # Difference in seconds

# Date
date = Date.today
date = Date.new(2024, 11, 25)
date = Date.parse("2024-11-25")

date.year             # 2024
date.month            # 11
date.day              # 25
date.wday             # 1 (Monday)

date + 7              # Add 7 days
date - 7              # Subtract 7 days
date.next_day         # Tomorrow
date.prev_day         # Yesterday
date.next_month       # Next month
date.prev_year        # Last year

# DateTime (combines Date and Time)
dt = DateTime.now
dt = DateTime.parse("2024-11-25T14:30:45")

Range

# Inclusive
(1..5).to_a           # [1, 2, 3, 4, 5]

# Exclusive
(1...5).to_a          # [1, 2, 3, 4]

# Methods
(1..10).include?(5)   # true
(1..10).cover?(5)     # true (faster)
(1..10).member?(5)    # true

(1..5).each { |n| puts n }
(1..5).map { |n| n * 2 }

# String ranges
('a'..'e').to_a       # ["a", "b", "c", "d", "e"]

# Case statement
case age
when 0..12
  "child"
when 13..19
  "teen"
else
  "adult"
end

Set

require 'set'

# Creation
set = Set.new([1, 2, 3])
set = Set[1, 2, 3]

# Operations
set.add(4)
set << 5
set.delete(3)

# Set operations
set1 | set2           # Union
set1 & set2           # Intersection
set1 - set2           # Difference
set1 ^ set2           # Symmetric difference

# Query
set.include?(2)       # true
set.empty?            # false
set.size              # 3

# Subset/superset
set1.subset?(set2)
set1.superset?(set2)

Best Practices

  1. Use Enumerable methods instead of manual loops
  2. Chain methods for readability: array.select(&:even?).map(&:to_s)
  3. Use symbol-to-proc (&:method_name) when possible
  4. Prefer File.open with blocks for automatic file closing
  5. Use fetch for hashes when you want to handle missing keys
  6. Leverage lazy enumerables for large collections
  7. Use Pathname for complex path operations

Anti-Patterns

Don't use for loops - use Enumerable methods ❌ Don't forget to close files - use blocks with File.open ❌ Don't use each for transformation - use mapDon't use each for filtering - use select or rejectDon't mutate arrays while iterating - use methods that return new arrays

Related Skills

  • ruby-oop - For understanding core classes
  • ruby-blocks-procs-lambdas - For working with Enumerable
  • ruby-metaprogramming - For advanced library usage

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

OpenCode

29.14%
按下载量换算41

Codex

21.92%
按下载量换算30

Claude Code

18.53%
按下载量换算26

windsurf

13.86%
按下载量换算19

Antigravity

7.39%
按下载量换算10

Gemini CLI

3.86%
按下载量换算5

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills