havenwood changed the topic of #ruby to: Ruby 3.3.5 (3.4.0-preview1) https://www.ruby-lang.org | Logs https://libera.irclog.whitequark.org/ruby
mtm has quit [Ping timeout: 248 seconds]
mtm has joined #ruby
chen has quit [Ping timeout: 260 seconds]
Munto has quit [Ping timeout: 260 seconds]
johnjaye has quit [Ping timeout: 252 seconds]
johnjaye has joined #ruby
gr33n7007h has quit [Ping timeout: 260 seconds]
gr33n7007h has joined #ruby
Triviality has joined #ruby
konsolebox has joined #ruby
madprops has joined #ruby
<madprops> what is the appropiate way to count line numbers of a file using ruby?
<madprops> im using file.readlines.size
<madprops> but i see the results are different to something like find . -type f -exec cat {} + | wc -l
<madprops> it counts the last line extra i guess
<madprops> maybe ruby's is more correct
Argorok has quit [Ping timeout: 252 seconds]
integral has quit [Ping timeout: 252 seconds]
kenyon has quit [Read error: Connection reset by peer]
kenyon has joined #ruby
integral has joined #ruby
Argorok has joined #ruby
bztrn has joined #ruby
bztrn has quit [Changing host]
bztrn has joined #ruby
grenierm has joined #ruby
cappy has joined #ruby
bztrn has quit [Ping timeout: 256 seconds]
Triviality has quit [Ping timeout: 252 seconds]
konsolebox has quit [Quit: .]
konsolebox has joined #ruby
victori has quit [Quit: ZNC 1.9.1 - https://znc.in]
BSaboia has quit [Quit: ZNC - https://znc.in]
mretka has quit [Quit: ZNC 1.8.2+deb2build5 - https://znc.in]
rdsm has quit [Quit: ZNC 1.8.2+deb2build5 - https://znc.in]
rdsm has joined #ruby
mretka has joined #ruby
cappy has quit [Quit: Leaving]
u0_a115 has joined #ruby
<isene> I have a string, "test this string" and want to extract parts of the text and capture that text in a variable - removing /s ../ should capture "s st" and leave the string like this "test thiring". What's the best/cleanest way?
smp has quit [Ping timeout: 255 seconds]
u0_a115 has quit [Ping timeout: 260 seconds]
u0_a115 has joined #ruby
u0_a1151 has joined #ruby
u0_a115 has quit [Ping timeout: 246 seconds]
Linux_Kerio has joined #ruby
Linux_Kerio has quit [Client Quit]
Linux_Kerio has joined #ruby
u0_a115 has joined #ruby
u0_a1151 has quit [Ping timeout: 245 seconds]
<gr33n7007h> isene: you can use String#gsub! and Regexp.last_match
u0_a115 has quit [Ping timeout: 246 seconds]
u0_a1151 has joined #ruby
<isene> Regexp.last_match = nice
<isene> thanks for that
<gr33n7007h> isene: no probs :)
u0_a115 has joined #ruby
u0_a1151 has quit [Ping timeout: 252 seconds]
smp has joined #ruby
u0_a1151 has joined #ruby
u0_a115 has quit [Ping timeout: 260 seconds]
smp has quit [Quit: ZNC 1.8.2 - https://znc.in]
smp has joined #ruby
TomyWork has joined #ruby
smp has quit [Ping timeout: 248 seconds]
smp has joined #ruby
smp has quit [Ping timeout: 252 seconds]
Triviality has joined #ruby
u0_a1151 has quit [Ping timeout: 264 seconds]
smp has joined #ruby
grenierm has quit [Quit: Client closed]
smp has quit [Quit: ZNC 1.8.2 - https://znc.in]
smp has joined #ruby
greybeard has joined #ruby
rvalue has quit [Read error: Connection reset by peer]
rvalue has joined #ruby
mtm has quit [Ping timeout: 260 seconds]
mtm has joined #ruby
graywolf has joined #ruby
smp has quit [Ping timeout: 255 seconds]
smp has joined #ruby
smp_ has joined #ruby
smp has quit [Ping timeout: 260 seconds]
smp_ is now known as smp
itaipu has quit [Ping timeout: 252 seconds]
o0x1eef has joined #ruby
itaipu has joined #ruby
user71 has joined #ruby
o0x1eef has quit [Ping timeout: 260 seconds]
patrick has quit [Ping timeout: 252 seconds]
patrick_ is now known as patrick
o0x1eef has joined #ruby
o0x1eef has quit [Ping timeout: 260 seconds]
Artea has quit [Quit: ZNC 1.8.2 - https://znc.in]
Artea has joined #ruby
victori has joined #ruby
jardsonto has joined #ruby
graywolf has quit [Quit: WeeChat 4.4.1]
Artea has quit [Quit: ZNC 1.8.2 - https://znc.in]
jardsonto has quit [Quit: leaving]
mtm has quit [Read error: Connection reset by peer]
mtm has joined #ruby
Artea has joined #ruby
u0_a115 has joined #ruby
u0_a1151 has joined #ruby
u0_a115 has quit [Ping timeout: 252 seconds]
u0_a115 has joined #ruby
u0_a1151 has quit [Ping timeout: 260 seconds]
u0_a115 has quit [Ping timeout: 246 seconds]
Artea has quit [Ping timeout: 272 seconds]
chen has joined #ruby
u0_a115 has joined #ruby
u0_a1151 has joined #ruby
u0_a115 has quit [Ping timeout: 265 seconds]
u0_a1151 has quit [Ping timeout: 248 seconds]
itaipu has quit [Ping timeout: 260 seconds]
itaipu has joined #ruby
o0x1eef has joined #ruby
o0x1eef has quit [Client Quit]
o0x1eef has joined #ruby
JonR has joined #ruby
Success has joined #ruby
o0x1eef has quit [Quit: Quit]
o0x1eef has joined #ruby
Pixi` has joined #ruby
Pixi has quit [Ping timeout: 252 seconds]
konsolebox has quit [Quit: .]
ih8u1 is now known as ih8u
Starfoxxes has joined #ruby
Vonter has quit [Ping timeout: 265 seconds]
Vonter has joined #ruby
<adam12> madprops: Beware file.readlines.size on large files.
<adam12> Since it will read entire string into memory and then create N strings in large Array.
<adam12> I'd open the file handle and then read smallish chunks, counting newlines within each chunk and incrementing some counter... atleast that's how I would do it naievely without benchmarking. But if you're always expecting small files it might not be worth it.
dstein64- has joined #ruby
dstein64 has quit [Ping timeout: 265 seconds]
dstein64- is now known as dstein64
<havenwood> madprops: I agree with adam12 that I'd avoid reading lines into an Array when unnecessary. Try just a: File.foreach(filename).count
<havenwood> That ^ will still iterate through the lines but it'll discard them as it goes by rather than storing them in an Array.
<adam12> That's a nice clean approach.
user71 has quit [Quit: Leaving]
brw has quit [Remote host closed the connection]
brw has joined #ruby
Linux_Kerio has quit [Ping timeout: 246 seconds]
nmollerup has quit [Quit: Leaving]
polishdub has quit [Ping timeout: 246 seconds]
polishdub has joined #ruby
TomyWork has quit [Remote host closed the connection]
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
greybeard has quit [Quit: Leaving.]
konsolebox has joined #ruby
<madprops> adam12, havenwood this is what I'm doing https://bpa.st/3CF5G
<madprops> i don't think im storing files to arrays