rabbit-slide-znz-kagoshima-rubykaigi01 2019.11.30

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9c0fe9880428231d072bad1b64fe697711cd7902c645323b231466ae4fbc34e4
4
+ data.tar.gz: ff576b197d348f0887657bb8933e2365b2ccc83e17f3c16120ae4ccac51cd221
5
+ SHA512:
6
+ metadata.gz: cec07a92e59df44a5c144560d65341dea3b3c50f78591fe3358709ad223e64c124cb15ede8f637936c272408ba059a407f21a935cd4dde66149c37bf04c44986
7
+ data.tar.gz: 76389566d0f318b530723d3edaa50edf31127ecb7715bb34c2d05ead5db0f5ab8e1d0747506dfe2f23c489e2fa951b787a2f32af91dfcd465022e49d55e30fcf
data/.rabbit ADDED
@@ -0,0 +1 @@
1
+ infrequent-use-ruby-features.md
@@ -0,0 +1,23 @@
1
+ # あまり知られていないRubyの便利機能
2
+
3
+ [鹿児島Ruby会議01](https://k-ruby.github.io/kagoshima-rubykaigi01/)での発表資料です。
4
+
5
+ ## For author
6
+
7
+ ### Show
8
+
9
+ rake
10
+
11
+ ### Publish
12
+
13
+ rake publish
14
+
15
+ ## For viewers
16
+
17
+ ### Install
18
+
19
+ gem install rabbit-slide-znz-kagoshima-rubykaigi01
20
+
21
+ ### Show
22
+
23
+ rabbit rabbit-slide-znz-kagoshima-rubykaigi01.gem
@@ -0,0 +1,17 @@
1
+ require "rabbit/task/slide"
2
+
3
+ # Edit ./config.yaml to customize meta data
4
+
5
+ spec = nil
6
+ Rabbit::Task::Slide.new do |task|
7
+ spec = task.spec
8
+ # spec.files += Dir.glob("doc/**/*.*")
9
+ # spec.files -= Dir.glob("private/**/*.*")
10
+ # spec.add_runtime_dependency("YOUR THEME")
11
+ end
12
+
13
+ desc "Tag #{spec.version}"
14
+ task :tag do
15
+ sh("git", "tag", "-a", spec.version.to_s, "-m", "Publish #{spec.version}")
16
+ sh("git", "push", "--tags")
17
+ end
@@ -0,0 +1,20 @@
1
+ ---
2
+ id: kagoshima-rubykaigi01
3
+ base_name: infrequent-use-ruby-features
4
+ tags:
5
+ - ruby
6
+ presentation_date: 2019/11/30
7
+ version: 2019.11.30
8
+ licenses: []
9
+ slideshare_id: ruby-199958323
10
+ speaker_deck_id: amarizhi-rareteinairubyfalsebian-li-ji-neng
11
+ ustream_id:
12
+ vimeo_id:
13
+ youtube_id:
14
+ author:
15
+ markup_language: :markdown
16
+ name: Kazuhiro NISHIYAMA
17
+ email: zn@mbf.nifty.com
18
+ rubygems_user: znz
19
+ slideshare_user: znzjp
20
+ speaker_deck_user: znz
@@ -0,0 +1,153 @@
1
+ # あまり知られていないRubyの便利機能
2
+
3
+ author
4
+ : Kazuhiro NISHIYAMA
5
+
6
+ content-source
7
+ : 鹿児島Ruby会議01
8
+
9
+ date
10
+ : 2019/11/30
11
+
12
+ institution
13
+ : 株式会社Ruby開発
14
+
15
+ allotted-time
16
+ : 10m
17
+
18
+ theme
19
+ : lightning-simple
20
+
21
+ # 自己紹介
22
+
23
+ - 西山 和広
24
+ - Ruby のコミッター
25
+ - twitter, github など: @znz
26
+ - 株式会社Ruby開発 www.ruby-dev.jp
27
+
28
+ # String#undump
29
+
30
+ - `String#dump` ⇄ `String#undump`
31
+ - since ruby 2.5
32
+ - `String#dump` ≠ `String#inspect`
33
+ - `String#undump` ≠ `eval`
34
+
35
+ # Hash#transform_*
36
+
37
+ - convert from Hash to Hash
38
+ - `Hash#transform_values{|v|...}`
39
+ - since ruby 2.4
40
+ - `Hash#transform_keys{|k|...}`
41
+ - since ruby 2.5
42
+
43
+ # Hash#to_h with block
44
+
45
+ - `Hash#to_h{|k,v|...}`
46
+ - with block since ruby 2.6
47
+ - without block since ruby 2.0.0
48
+
49
+ # warn with uplevel:
50
+
51
+ - old: `warn "#{caller(1, 1)[0]}: warning: message"`
52
+ - new: `warn "message", uplevel: 1`
53
+ - since ruby 2.5
54
+
55
+ # abort(message)
56
+
57
+ - `abort("failed message")`
58
+ - ≒ `warn("failed message"); exit(false)`
59
+
60
+ # rand(range)
61
+
62
+ - `rand(range)`
63
+ - `rand(1..6)`
64
+ - since ruby 1.9.3
65
+ - NG: `rand(endless_range)`
66
+ - `rand(1..)`
67
+ - `Errno::EDOM (Numerical argument out of domain)`
68
+
69
+ # String.new
70
+
71
+ - `String.new.encoding` → ASCII-8BIT
72
+ - `String.new(encoding: 'euc-jp').encoding` → EUC-JP
73
+ - `''.dup` → UTF-8 (script encoding)
74
+ - `+''` → UTF-8 (script encoding)
75
+ - `''.+@` (for method chain)
76
+ - (useful with frozen string literal)
77
+
78
+ # String#gsub(pattern, hash)
79
+
80
+ ```ruby
81
+ string.gsub(/['&"<>]/, {
82
+ "'" => '&#39;',
83
+ '&' => '&amp;',
84
+ '"' => '&quot;',
85
+ '<' => '&lt;',
86
+ '>' => '&gt;',
87
+ })
88
+ ```
89
+
90
+ # Regexp.union
91
+
92
+ ```ruby
93
+ Regexp.union #=> /(?!)/
94
+ Regexp.union("penzance") #=> /penzance/
95
+ Regexp.union("a+b*c") #=> /a\+b\*c/
96
+ Regexp.union("skiing", "sledding")
97
+ Regexp.union(["skiing", "sledding"])
98
+ #=> /skiing|sledding/
99
+ Regexp.union(/dogs/, /cats/i)
100
+ #=> /(?-mix:dogs)|(?i-mx:cats)/
101
+ ```
102
+
103
+ # String#*_with?
104
+
105
+ ```ruby
106
+ "hello".start_with?("hell") #=> true
107
+ "hello".start_with?(/H/i) #=> true
108
+
109
+ # returns true if one of the prefixes matches.
110
+ "hello".start_with?("heaven", "hell") #=> true
111
+ "hello".start_with?("heaven", "paradise") #=> false
112
+
113
+ "hello".end_with?("ello") #=> true
114
+
115
+ # returns true if one of the +suffixes+ matches.
116
+ "hello".end_with?("heaven", "ello") #=> true
117
+ "hello".end_with?("heaven", "paradise") #=> false
118
+ ```
119
+
120
+ - NG: `starts_with?`, `ends_with?`
121
+
122
+ # String#{prepend,delete_prefix,delete_suffix,chomp,chop}
123
+
124
+ ```ruby
125
+ "end".prepend("prep") #=> "prepend"
126
+ "prefix".delete_prefix("pre") #=> "fix"
127
+ "suffix".delete_suffix("fix") #=> "suf"
128
+ "suffix".chomp("fix") #=> "fix"
129
+ "hello\r\n".chomp #=> "hello"
130
+ "hello\r\n".chop #=> "hello"
131
+ ```
132
+
133
+ # String#{delete,tr}
134
+
135
+ ```ruby
136
+ "hello".delete "l","lo" #=> "heo"
137
+ "hello".delete "lo" #=> "he"
138
+ "hello".delete "aeiou", "^e" #=> "hell"
139
+ "hello".delete "ej-m" #=> "ho"
140
+ "hello".tr('el', 'ip') #=> "hippo"
141
+ "hello".tr('a-y', 'b-z') #=> "ifmmp"
142
+ "hello".tr('^aeiou', '*') #=> "*e**o"
143
+ ```
144
+
145
+ # 参考文献
146
+
147
+ - リファレンスマニュアル
148
+ <https://docs.ruby-lang.org/ja/>
149
+ - 間違いなどを見つけたら
150
+ <https://github.com/rurema/doctree>
151
+ - もっと気軽に確認したいなら
152
+ <https://ruby-jp.github.io/>
153
+ ruby-jp Slack の #rurema など
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rabbit-slide-znz-kagoshima-rubykaigi01
3
+ version: !ruby/object:Gem::Version
4
+ version: 2019.11.30
5
+ platform: ruby
6
+ authors:
7
+ - Kazuhiro NISHIYAMA
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-12-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rabbit
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2.0.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 2.0.2
27
+ description: "[鹿児島Ruby会議01](https://k-ruby.github.io/kagoshima-rubykaigi01/)での発表資料です。"
28
+ email:
29
+ - zn@mbf.nifty.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".rabbit"
35
+ - README.md
36
+ - Rakefile
37
+ - config.yaml
38
+ - infrequent-use-ruby-features.md
39
+ - pdf/kagoshima-rubykaigi01-infrequent-use-ruby-features.pdf
40
+ homepage: http://slide.rabbit-shocker.org/authors/znz/kagoshima-rubykaigi01/
41
+ licenses: []
42
+ metadata: {}
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubyforge_project:
59
+ rubygems_version: 2.7.6
60
+ signing_key:
61
+ specification_version: 4
62
+ summary: あまり知られていないRubyの便利機能
63
+ test_files: []