-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.irb_history
302 lines (302 loc) · 5.51 KB
/
.irb_history
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
17 + 42
firstname = "hoge"
"#{firstname}fuga"
puts "hoge"
print "hoge"
"foobar".length
"".empty?
"a".empty?
if s.nil?\
puts "hoge"\
elsif t.nil?\
puts "fuu"\
else\
puts "bar"\
end
x = "foo"
puts x if x.nil?
puts "hoge" if !x.empty?
nil.to_s
nil.to_s.empty?
puts "hoge" unless x.empty?
"racecar".length
"racecar".reverse
s = "racecar"
s.reverse == s
def string_message(str = '')\
if str.empty?\
"It's an empty string!"\
else\
"The string is nonempty."\
end\
end
puts string_message("hoge")
puts string_message
"foo bar baz".split
"fooxbarxbaz".split("x")
a = "fooxbarxbaz".split("x")
a.first
a.last
a.empty?
a.include("hoge")
a.include?("hoge")
a.sort
a.reverse
a.suffle
a.shuffle
a
0..9
(0..9).to_a
(0..9).to_array
(0..9).to_param
a[1..-1\
]
a = "A man, a plan, a canal, Panama".split(',')
a
a.to_param
a.join
s = a.join
s
s.split.join
s.split.join!
s.split!.join!
s.split
s
s.split!
s.split()!
s.split!()
s.split.join
s.split.join.downcase
a..z
"a..z"
"a".."z"
"a".."z".to_a
("a".."z").to_a
("a".."z").to_a[6]
(1..5).each do |i|\
puts i\
end
3.times do\
puts "hoge"\
end
(1..5).map do |i|\
i++\
end
(1..5).map do |i|\
i +1\
end
(1..5).map(&:to_s)
(0..16).each do |i|\
puts i^2\
end
(0..16).each do |i|\
puts i**2\
end
def yeller(arr)\
return arr.map(&:upcase.join)\
end
yeller(["o","l","d"])
def yeller(arr)\
return arr.map(&:upcase:join)\
end
def yeller(arr)\
return arr.map do |s|\
end
def yeller(arr)\
return arr.map do |s|\
end
def yeller(arr)\
return arr.map do |s|\
s.upcase\
end.join\
end
yeller(["o","l","d"])
def random_subdomain\
return (a..z).shuffle[0:7].join\
end
def random_subdomain\
return (a..z).shuffle[0..7].join\
end
random_subdomain
def random_subdomain\
return ("a".."z").shuffle[0..7].join\
end
random_subdomain
def random_subdomain\
return ("a".."z").to_a.shuffle[0..7].join\
end
random_subdomain
random_subdomain
random_subdomain
("a".."z")
p :name
puts :name
hoge = {one: "uno", two: "dos", three: "tres"}
hoge
hoge.each do |key, val|\
"#{key}のスペイン語は#{val}です"\
end
hoge.each do |key, val|\
echo "#{key}のスペイン語は#{val}です"\
end
hoge.each do |key, val|\
puts "#{key}のスペイン語は#{val}です"\
end
{ "a" => 100, "b" => 200 }.merge({ "b" => 300 })
"foo".class
h = Hash.new(0)
hash[:a]
h[:a]
Range.new(1,10)
class Word\
def palindrome?(string)\
string == string.reverse\
end\
end
w = Word.new
w.palindrome?("foobar")
w.palindrome?("aaaa")
class Word < String\
def palindrome?\
self == self.revers\
end\
end
class Word < String\
def palindrome?\
self == self.revers\
end\
end
s = Word.new("hoge")
s.plaindrome?
s.palindrome?
class Word < String\
def palindrome?\
self == self.reverse\
end\
end
s.palindrome?
a = Word.new("aaaa")
a.palindrome?
s.length
Hash.superclass
Hash.superclass.superclass
Symbol.superclass.superclass
Range.superclass.superclass
Range.superclass
Symbol.superclass
controller = StaticPagesController.new
controller.class
controller.superclass
controller.class.superclass
controller.class.superclass.superclass
controller.class.superclass.superclass.superclass
controller.class.superclass.superclass.superclass.superclass
controller.class.superclass.superclass.superclass.superclass.superclass
User.new
require ./example_user
require './example_user'
example = User.new
example.name
example.name = 'hoge'
example
User.new
user = User.new(name: "Michael Hartl", email: "[email protected]")
user.valid?
user
user.save
user
user.email
user.email.instance
user.email.property
user.email.class
User.find(1\
)
User.find(3)
User.find_by(email: "[email protected]")
User.first
User.all
User.find_by_name("Michael Hartl")
User.all
User.all.class
User.all.class.superclass
User.all.class.superclass.superclass
User.all.length
use
user
user.email
user.email = "[email protected]"
user
user.save
user
user.created_at
user.created_at = 1.year.ago
user
user.cretated_at
user.createdat
user.created/at
user.created/at
user.created_at
user.save
u = User.new
u = User.new
u
u.valid?
u.errors.messages
user = User.new(name: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
user = User.new(:name "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
user = User.new(name: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
user
user.valid?
user.errors.messages
User.create(name: "Michael Hartl", email: "[email protected]", password: "foobar", password_confirmation: "foobar")
user = User.find_by(email: "[email protected]")
user.password_digest
user.authenticate("foobar")
user.authenticate("for")
User.count
User.count
User.first
User.first
user = User.first
user.update_attributes(password: "foobar")
User.first
SecureRandom.urlsafe_base64
User.pagenate(1)
User.paginate(1)
User.paginate(page: 1)
user = User.first
user.admin?
user.toggle!(:admin)
true
user.admin?
micropost = user.microposts.create(content: "Lorem ipsum")
user = User.first
micropost = user.microposts.create(content: "Lorem ipsum")
user = User.first
micropost = user.microposts.create(content: "Lorem ipsum")
user.microposts.build(content: "hoge")
micropost
micropost = user.micropost.create(content: "Lorem ipsum")
micropost = user.microposts.create(content: "Lorem ipsum")
user.micropost
user.microposts
user.microposts.build
user.microposts.new
user = User.first
user
Micropost
Micropost.first
Microposts.first
Micropost
sql
Micropost
User
Session
Micropost
user
user = User.first
user = User.first
user
user.micropost
user.id
user.microposts