Submit Search
Upload
あまり知られていないRubyの便利機能
•
0 likes
•
203 views
K
Kazuhiro Nishiyama
Follow
[鹿児島Ruby会議01](https://k-ruby.github.io/kagoshima-rubykaigi01/)での発表資料です。
Read less
Read more
Technology
Report
Share
Report
Share
1 of 15
Download now
Download to read offline
Recommended
Sensor architecturestartingpoint
Sensor architecturestartingpoint
Prashun Javeri
Build reliable, traceable, distributed systems with ZeroMQ
Build reliable, traceable, distributed systems with ZeroMQ
Robin Xiao
Difference between php and node
Difference between php and node
Nguyễn Ngọc Phương
appborg, coffeesurgeon, moof, logging-system
appborg, coffeesurgeon, moof, logging-system
endian7000
The Rust Programming Language
The Rust Programming Language
Mario Alexandro Santini
Coding in the context era
Coding in the context era
lestrrat
Xen Summit 2008 Tokyo - Operating Xen domains through LL(Perl/Python) with li...
Xen Summit 2008 Tokyo - Operating Xen domains through LL(Perl/Python) with li...
Gosuke Miyashita
Building a REST API with Node.js and MongoDB
Building a REST API with Node.js and MongoDB
VivochaLabs
Recommended
Sensor architecturestartingpoint
Sensor architecturestartingpoint
Prashun Javeri
Build reliable, traceable, distributed systems with ZeroMQ
Build reliable, traceable, distributed systems with ZeroMQ
Robin Xiao
Difference between php and node
Difference between php and node
Nguyễn Ngọc Phương
appborg, coffeesurgeon, moof, logging-system
appborg, coffeesurgeon, moof, logging-system
endian7000
The Rust Programming Language
The Rust Programming Language
Mario Alexandro Santini
Coding in the context era
Coding in the context era
lestrrat
Xen Summit 2008 Tokyo - Operating Xen domains through LL(Perl/Python) with li...
Xen Summit 2008 Tokyo - Operating Xen domains through LL(Perl/Python) with li...
Gosuke Miyashita
Building a REST API with Node.js and MongoDB
Building a REST API with Node.js and MongoDB
VivochaLabs
MongoDB, Node.js And You: PART II
MongoDB, Node.js And You: PART II
Mitch Pirtle
Node.js for Rubists
Node.js for Rubists
Sagiv Ofek
Groovy a Scripting Language for Java
Groovy a Scripting Language for Java
Charles Anderson
20140918 ruby kaigi2014
20140918 ruby kaigi2014
Hiroshi SHIBATA
Ruby's GC 20
Ruby's GC 20
Narihiro Nakamura
Introduction to Python
Introduction to Python
Sway Wang
The art of concurrent programming
The art of concurrent programming
Iskren Chernev
lilo.linux.or.jp を buster から bullseye に上げた
lilo.linux.or.jp を buster から bullseye に上げた
Kazuhiro Nishiyama
小規模個人アプリをRails 7.xにバージョンアップした話
小規模個人アプリをRails 7.xにバージョンアップした話
Kazuhiro Nishiyama
Ruby リファレンスマニュアル改善計画 2022 進捗報告
Ruby リファレンスマニュアル改善計画 2022 進捗報告
Kazuhiro Nishiyama
fukuoka03-rubima-reboot-rubyist-magazine-reboot.pdf
fukuoka03-rubima-reboot-rubyist-magazine-reboot.pdf
Kazuhiro Nishiyama
rubykaigi2022-rurema-history-and-future.pdf
rubykaigi2022-rurema-history-and-future.pdf
Kazuhiro Nishiyama
qemuのriscv64にDebianを入れてみた
qemuのriscv64にDebianを入れてみた
Kazuhiro Nishiyama
systemd 再入門
systemd 再入門
Kazuhiro Nishiyama
Ruby 3.0.0 コネタ集
Ruby 3.0.0 コネタ集
Kazuhiro Nishiyama
livedoor天気API終了対応
livedoor天気API終了対応
Kazuhiro Nishiyama
Wireguard 実践入門
Wireguard 実践入門
Kazuhiro Nishiyama
workflow,job,step の使い分けの基準を考える
workflow,job,step の使い分けの基準を考える
Kazuhiro Nishiyama
Dockerのオフィシャルrubyイメージとは?
Dockerのオフィシャルrubyイメージとは?
Kazuhiro Nishiyama
チャットボットのススメ
チャットボットのススメ
Kazuhiro Nishiyama
Dokku の紹介
Dokku の紹介
Kazuhiro Nishiyama
Action Cableで簡易チャットを作ってみた
Action Cableで簡易チャットを作ってみた
Kazuhiro Nishiyama
More Related Content
What's hot
MongoDB, Node.js And You: PART II
MongoDB, Node.js And You: PART II
Mitch Pirtle
Node.js for Rubists
Node.js for Rubists
Sagiv Ofek
Groovy a Scripting Language for Java
Groovy a Scripting Language for Java
Charles Anderson
20140918 ruby kaigi2014
20140918 ruby kaigi2014
Hiroshi SHIBATA
Ruby's GC 20
Ruby's GC 20
Narihiro Nakamura
Introduction to Python
Introduction to Python
Sway Wang
The art of concurrent programming
The art of concurrent programming
Iskren Chernev
What's hot
(7)
MongoDB, Node.js And You: PART II
MongoDB, Node.js And You: PART II
Node.js for Rubists
Node.js for Rubists
Groovy a Scripting Language for Java
Groovy a Scripting Language for Java
20140918 ruby kaigi2014
20140918 ruby kaigi2014
Ruby's GC 20
Ruby's GC 20
Introduction to Python
Introduction to Python
The art of concurrent programming
The art of concurrent programming
More from Kazuhiro Nishiyama
lilo.linux.or.jp を buster から bullseye に上げた
lilo.linux.or.jp を buster から bullseye に上げた
Kazuhiro Nishiyama
小規模個人アプリをRails 7.xにバージョンアップした話
小規模個人アプリをRails 7.xにバージョンアップした話
Kazuhiro Nishiyama
Ruby リファレンスマニュアル改善計画 2022 進捗報告
Ruby リファレンスマニュアル改善計画 2022 進捗報告
Kazuhiro Nishiyama
fukuoka03-rubima-reboot-rubyist-magazine-reboot.pdf
fukuoka03-rubima-reboot-rubyist-magazine-reboot.pdf
Kazuhiro Nishiyama
rubykaigi2022-rurema-history-and-future.pdf
rubykaigi2022-rurema-history-and-future.pdf
Kazuhiro Nishiyama
qemuのriscv64にDebianを入れてみた
qemuのriscv64にDebianを入れてみた
Kazuhiro Nishiyama
systemd 再入門
systemd 再入門
Kazuhiro Nishiyama
Ruby 3.0.0 コネタ集
Ruby 3.0.0 コネタ集
Kazuhiro Nishiyama
livedoor天気API終了対応
livedoor天気API終了対応
Kazuhiro Nishiyama
Wireguard 実践入門
Wireguard 実践入門
Kazuhiro Nishiyama
workflow,job,step の使い分けの基準を考える
workflow,job,step の使い分けの基準を考える
Kazuhiro Nishiyama
Dockerのオフィシャルrubyイメージとは?
Dockerのオフィシャルrubyイメージとは?
Kazuhiro Nishiyama
チャットボットのススメ
チャットボットのススメ
Kazuhiro Nishiyama
Dokku の紹介
Dokku の紹介
Kazuhiro Nishiyama
Action Cableで簡易チャットを作ってみた
Action Cableで簡易チャットを作ってみた
Kazuhiro Nishiyama
Ruby svn to git
Ruby svn to git
Kazuhiro Nishiyama
Ruby 2.6 Update
Ruby 2.6 Update
Kazuhiro Nishiyama
最近のrubyのインストール方法
最近のrubyのインストール方法
Kazuhiro Nishiyama
Language update 2018 - ruby
Language update 2018 - ruby
Kazuhiro Nishiyama
systemdでよく使うサブコマンド
systemdでよく使うサブコマンド
Kazuhiro Nishiyama
More from Kazuhiro Nishiyama
(20)
lilo.linux.or.jp を buster から bullseye に上げた
lilo.linux.or.jp を buster から bullseye に上げた
小規模個人アプリをRails 7.xにバージョンアップした話
小規模個人アプリをRails 7.xにバージョンアップした話
Ruby リファレンスマニュアル改善計画 2022 進捗報告
Ruby リファレンスマニュアル改善計画 2022 進捗報告
fukuoka03-rubima-reboot-rubyist-magazine-reboot.pdf
fukuoka03-rubima-reboot-rubyist-magazine-reboot.pdf
rubykaigi2022-rurema-history-and-future.pdf
rubykaigi2022-rurema-history-and-future.pdf
qemuのriscv64にDebianを入れてみた
qemuのriscv64にDebianを入れてみた
systemd 再入門
systemd 再入門
Ruby 3.0.0 コネタ集
Ruby 3.0.0 コネタ集
livedoor天気API終了対応
livedoor天気API終了対応
Wireguard 実践入門
Wireguard 実践入門
workflow,job,step の使い分けの基準を考える
workflow,job,step の使い分けの基準を考える
Dockerのオフィシャルrubyイメージとは?
Dockerのオフィシャルrubyイメージとは?
チャットボットのススメ
チャットボットのススメ
Dokku の紹介
Dokku の紹介
Action Cableで簡易チャットを作ってみた
Action Cableで簡易チャットを作ってみた
Ruby svn to git
Ruby svn to git
Ruby 2.6 Update
Ruby 2.6 Update
最近のrubyのインストール方法
最近のrubyのインストール方法
Language update 2018 - ruby
Language update 2018 - ruby
systemdでよく使うサブコマンド
systemdでよく使うサブコマンド
Recently uploaded
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
Neo4j
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
marketing932765
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
UiPathCommunity
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Mark Goldstein
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
LoriGlavin3
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
Kari Kakkonen
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
Nathaniel Shimoni
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
Bernd Ruecker
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
itnewsafrica
2024 April Patch Tuesday
2024 April Patch Tuesday
Ivanti
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Pim van der Noll
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
Lonnie McRorey
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Alkin Tezuysal
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
Ingrid Airi González
A Framework for Development in the AI Age
A Framework for Development in the AI Age
Cprime
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
Wes McKinney
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
LoriGlavin3
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
TopCSSGallery
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
Knoldus Inc.
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
Farhan Tariq
Recently uploaded
(20)
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
2024 April Patch Tuesday
2024 April Patch Tuesday
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
A Framework for Development in the AI Age
A Framework for Development in the AI Age
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
あまり知られていないRubyの便利機能
1.
あまり知られていないRuby の便利機能 Kazuhiro NISHIYAMA 鹿児島Ruby会議01 2019/11/30 株式会社Ruby開発 Powered by
Rabbit 2.2.1
2.
自己紹介 西山 和広 Ruby のコミッター twitter,
github など: @znz 株式会社Ruby開発 www.ruby-dev.jp 1/14
3.
String#undump String#dump ⇄ String#undump since
ruby 2.5 String#dump ≠ String#inspect String#undump ≠ eval 2/14
4.
Hash#transform_* convert from Hash
to Hash Hash#transform_values{|v|...} since ruby 2.4 Hash#transform_keys{|k|...} since ruby 2.5 3/14
5.
Hash#to_h with block Hash#to_h{|k,v|...} with
block since ruby 2.6 without block since ruby 2.0.0 4/14
6.
warn with uplevel: old:
warn "#{caller(1, 1)[0]}: warning: message" new: warn "message", uplevel: 1 since ruby 2.5 5/14
7.
abort(message) abort("failed message") ≒ warn("failed
message"); exit(false) 6/14
8.
rand(range) rand(range) rand(1..6) since ruby 1.9.3 NG:
rand(endless_range) rand(1..) Errno::EDOM (Numerical argument out of domain) 7/14
9.
String.new String.new.encoding → ASCII-8BIT String.new(encoding:
'euc- jp').encoding → EUC-JP ''.dup → UTF-8 (script encoding) +'' → UTF-8 (script encoding) ''.+@ (for method chain) (useful with frozen string literal) 8/14
10.
String#gsub(pattern, hash) string.gsub(/['&"<>]/, { "'" =>
''', '&' => '&', '"' => '"', '<' => '<', '>' => '>', }) 9/14
11.
Regexp.union Regexp.union #=> /(?!)/ Regexp.union("penzance")
#=> /penzance/ Regexp.union("a+b*c") #=> /a+b*c/ Regexp.union("skiing", "sledding") Regexp.union(["skiing", "sledding"]) #=> /skiing|sledding/ Regexp.union(/dogs/, /cats/i) #=> /(?-mix:dogs)|(?i-mx:cats)/ 10/14
12.
String#*_with? "hello".start_with?("hell") #=> true "hello".start_with?(/H/i)
#=> true # returns true if one of the prefixes matches. "hello".start_with?("heaven", "hell") #=> true "hello".start_with?("heaven", "paradise") #=> false "hello".end_with?("ello") #=> true # returns true if one of the +suffixes+ matches. "hello".end_with?("heaven", "ello") #=> true "hello".end_with?("heaven", "paradise") #=> false NG: starts_with?, ends_with? 11/14
13.
String#{prepend,delet e_prefix,delete_suffix,c homp,chop} "end".prepend("prep") #=> "prepend" "prefix".delete_prefix("pre")
#=> "fix" "suffix".delete_suffix("fix") #=> "suf" "suffix".chomp("fix") #=> "fix" "hellorn".chomp #=> "hello" "hellorn".chop #=> "hello" 12/14
14.
String#{delete,tr} "hello".delete "l","lo" #=>
"heo" "hello".delete "lo" #=> "he" "hello".delete "aeiou", "^e" #=> "hell" "hello".delete "ej-m" #=> "ho" "hello".tr('el', 'ip') #=> "hippo" "hello".tr('a-y', 'b-z') #=> "ifmmp" "hello".tr('^aeiou', '*') #=> "*e**o" 13/14
15.
参考文献 リファレンスマニュアル https://docs.ruby-lang.org/ja/ 間違いなどを見つけたら https://github.com/rurema/doctree もっと気軽に確認したいなら https://ruby-jp.github.io/ ruby-jp Slack の
#rurema など 14/14Powered by Rabbit 2.2.1
Download now