Francisco has quit [Remote host closed the connection]
Francisco has joined #ruby
herbmillerjr has quit [Quit: Konversation terminated!]
orbyt_ has joined #ruby
roshanavand has quit [Ping timeout: 252 seconds]
Blaguvest has quit []
AJA4350 has quit [Quit: AJA4350]
P1RATEZ has quit []
mroutis has joined #ruby
braincrash has quit [Quit: bye bye]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
braincrash has joined #ruby
podlech has joined #ruby
dellavg_ has joined #ruby
podlech has quit [Client Quit]
orbyt_ has joined #ruby
podlech has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
code_zombie has quit [Quit: Leaving]
RougeR has quit [Ping timeout: 252 seconds]
jasmith has quit [Quit: Leaving]
hahuang6- is now known as hahuang65
arescorpio has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
arescorpio has quit [Remote host closed the connection]
Dimik has quit [Ping timeout: 272 seconds]
cagomez has quit [Remote host closed the connection]
cagomez has joined #ruby
sarmiena_ has joined #ruby
sarmiena_ has quit [Client Quit]
sarmiena_ has joined #ruby
cagomez has quit [Ping timeout: 272 seconds]
<Radar>
2 protips for junior rubyists: 1( attr_reader != attr_accessor (plz learn the difference) 2) keyword arguments were added in Ruby 2.0 (circa end of 2013) and will drastically reduce the code you write in initialize. Please use them.
<Radar>
Signed, someone who is reviewing many, many junior Rubyist coding tests.
<Radar>
THIRD BONUS PROTIP: Look at the Enumerable module. Gaze into it. Let it envelope you. `find` yourself within it. `select` from it particular methods that will help you. `each_with_object`, etc, etc, etc.
<baweaver>
Oh come now Radar, that's just sad, only two enumerable puns? I reject that notion
<Radar>
baweaver: Sorry, I was all? out of puns. I didn't have any? more.
<Radar>
But now I am reading the documentation to .collect some more. I'll tell you the .first one I come across. p.s. inject is bad okay
<baweaver>
I'm sure you'll filter out a few more (bonus for 2.6 syntax :D )
<jacobat>
Is there an easy way to capture keywords args into a hash?
<jacobat>
I could change the method signature to use a hash instead of kw args but that's not what I'm looking for
<tbuehlmann>
`def foo(**kwargs); kwargs; end` where kwargs will be a hash, do you mean that?
<jacobat>
No, I want to maintain a signature like `def foo(a:, b:)` - but in the body of the method I want an easy way to convert it into a hash, or otherwise use a subset of the arguments.
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rubydoc has quit [Remote host closed the connection]
raulp has joined #ruby
aufi_ has joined #ruby
GodFather has joined #ruby
kurko_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
aufi_ has quit [Ping timeout: 272 seconds]
clemens3 has quit [Ping timeout: 244 seconds]
schneider has joined #ruby
DTZUZO has joined #ruby
arup_r has quit [Ping timeout: 252 seconds]
darkhanb has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
lxsameer has quit [Ping timeout: 245 seconds]
jcarl43 has joined #ruby
duderonomy has joined #ruby
truenito has joined #ruby
truenito has quit [Remote host closed the connection]
johnny56 has joined #ruby
duderonomy has quit [Client Quit]
duderonomy has joined #ruby
duderonomy has quit [Client Quit]
dbz has joined #ruby
cthulchu has joined #ruby
dbz has quit [Ping timeout: 268 seconds]
dmitch has quit [Ping timeout: 252 seconds]
bkxd has joined #ruby
evdubs_ has quit [Remote host closed the connection]
phaul has quit [Ping timeout: 244 seconds]
evdubs_ has joined #ruby
* baweaver
wanders in
snickers has joined #ruby
yohji has quit [Remote host closed the connection]
darkhanb has joined #ruby
sarmiena_ has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
dbz has joined #ruby
conta1 has joined #ruby
DTZUZO has quit [Ping timeout: 244 seconds]
DTZUZO_ has joined #ruby
bkxd has joined #ruby
uplime has quit [Ping timeout: 268 seconds]
Francisco has joined #ruby
Francisco has quit [Client Quit]
dbz has quit [Remote host closed the connection]
ogres has quit [Quit: Connection closed for inactivity]
Fr4n has quit [Read error: Connection reset by peer]
dbz has joined #ruby
dbz has quit [Read error: Connection reset by peer]
dbz has joined #ruby
chouhoulis has quit [Ping timeout: 252 seconds]
Sauvin has quit [Ping timeout: 246 seconds]
duderonomy has joined #ruby
* Eiam
hands baweaver a beer so they can settle in
Nicmavr has quit [Read error: Connection reset by peer]
bkxd has quit [Read error: Connection reset by peer]
xfbs has quit [Quit: afk]
Nicmavr has joined #ruby
bak1an has joined #ruby
xfbs has joined #ruby
schneider has quit [Ping timeout: 268 seconds]
xfbs has quit [Client Quit]
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sameerynho has joined #ruby
schneider has joined #ruby
Sauvin has joined #ruby
sauvin_ has joined #ruby
phaul has joined #ruby
bkxd has joined #ruby
Sauvin has quit [Ping timeout: 252 seconds]
beowuff has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
schneider has quit [Quit: WeeChat 2.0.1]
dbz has quit [Remote host closed the connection]
roshanavand has joined #ruby
uplime has joined #ruby
uplime has joined #ruby
Dbugger has joined #ruby
GodFather has quit [Ping timeout: 240 seconds]
uplime has quit [Client Quit]
kurko_ has joined #ruby
uplime has joined #ruby
xfbs has joined #ruby
bkxd has joined #ruby
venmx has quit [Ping timeout: 260 seconds]
bkxd has quit [Read error: Connection reset by peer]
GodFather has joined #ruby
bkxd has joined #ruby
ellcs has joined #ruby
kapil____ has joined #ruby
bkxd has quit [Ping timeout: 252 seconds]
za1b1tsu has quit [Ping timeout: 252 seconds]
clemens3 has joined #ruby
agent_white has joined #ruby
Terens has quit [Ping timeout: 252 seconds]
deathwishdave has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mroutis has joined #ruby
conta1 has quit [Quit: conta1]
kurko_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
impermanence has joined #ruby
bkxd has joined #ruby
dviola has joined #ruby
sauvin_ has quit [Read error: Connection reset by peer]
improv42 has joined #ruby
weaksauce has joined #ruby
kurko_ has joined #ruby
improv42 has quit [Remote host closed the connection]
<cthulchu>
we can next in each_line, right?
<apeiros_>
yes
<cthulchu>
thanks
krawchyk has joined #ruby
improv42 has joined #ruby
conta1 has joined #ruby
clemens3 has quit [Ping timeout: 252 seconds]
discopatrick has quit [Quit: Connection closed for inactivity]
bkxd has quit [Read error: Connection reset by peer]
eckhardt has joined #ruby
clemens3 has joined #ruby
bkxd has joined #ruby
SeepingN has quit [Quit: The system is going down for reboot NOW!]
improv42 has quit [Read error: Connection reset by peer]
improv42 has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
GodFather has quit [Ping timeout: 245 seconds]
bkxd has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
GodFather has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<cthulchu>
wow
<cthulchu>
I found something weird
<cthulchu>
looks like it's possible for a hash to have fields with the same keys
bkxd has joined #ruby
<cthulchu>
I didn't know it about them
<cthulchu>
so if I set a hash explicitly like hash={"qwe":""} and then do hash["qwe"]="bar", it will end up having two records
<cthulchu>
with the same key but different values...
<cthulchu>
hm
<cthulchu>
Ruby is amazing
<phaul>
Ruby is amazing, but you are mistaken there
<phaul>
{"qwe":""} is { :qwe => '' }
<phaul>
so not the same keys
<phaul>
one is symbol the other is string
<cthulchu>
err
<cthulchu>
omfg
<cthulchu>
I didn't mean symbols!
<cthulchu>
thanks! :)
<phaul>
np :)
teej has joined #ruby
<cthulchu>
so... the correct way would be... asd = {qwe = "qwe", asd = "asd"}?
greengriminal has joined #ruby
<cthulchu>
oh
<cthulchu>
actually
<cthulchu>
should be {"qwe":"qwe"}
<cthulchu>
I guess
<uplime>
{"abcd" => "efgh"}
<greengriminal>
Hey all I'm currently using Ruby 2.3.4 and the following (0.99 + (1.0 * 0.025)).round(2) = 1.01 but in Ruby 2.3.7 I get 1.02
<cthulchu>
oh, ok, thanks
<cthulchu>
=> is the arrow function?
<phaul>
cthulchu: we used to have only one hash syntax. the => syntax. then they decided to give a syntactic sugar for symbol keys. that's when all the confusion started
<uplime>
cthulchu: its not a function
<phaul>
not function. it's a special syntax to define hashes
<cthulchu>
ok, thanks
<uplime>
key => value
<cthulchu>
great, I'll do it then
<uplime>
key_as_symbol: vlaue
<greengriminal>
For that matter I get the same output on 2.4.0 as well
<phaul>
cool. even that works :) how versatile concatenation can be :)
rubydoc has quit [Remote host closed the connection]
phaul has quit [Quit: bye]
phaul has joined #ruby
ivanskie has joined #ruby
ruurd has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rubydoc has joined #ruby
<cthulchu>
ok, I'm excited
<cthulchu>
I have this Android log that I parse in the runtime
<cthulchu>
and there was an issue cuz the log grew rapidly and I didn't have a good way to solve the issue.
<cthulchu>
I can't delete it cuz Genymotion won't create a file after that
SeepingN has joined #ruby
<cthulchu>
but what I can do is remember the line number that I used before and do my analysis from there on
<cthulchu>
or rather file reading
<cthulchu>
sounds super cool
<cthulchu>
although I would have to use @@
<cthulchu>
but hey, it's not that bad
mroutis has quit [Ping timeout: 272 seconds]
spiette has quit [Ping timeout: 260 seconds]
<cthulchu>
so the question is... how do I read file starting from a specific line? I looked at arguments in each_line and it seems to have only two: separator and limit
<phaul>
havenwood: sorry my rubydoc.info.stdlib/core/ prefix paste bot is in very early stages :)
<havenwood>
phaul: I think the docs.ruby-lang.org docs would make the best ri links.
<havenwood>
phaul: nice
<apeiros_>
you shouldn't use non-csv reading methods to advance in a csv (assuming the file does not consist of partially non-csv values)
<apeiros_>
reason: a single csv row may very well contain newlines
<apeiros_>
TIL pread, though. nice.
jcalla has quit [Quit: Leaving]
jcalla has joined #ruby
deathwishdave has joined #ruby
LiftLeft2 has quit [Ping timeout: 240 seconds]
dmitch has joined #ruby
greengriminal has quit [Quit: This computer has gone to sleep]
<phaul>
but if this is just continuing from where you left of when that was an EOF (assuming that EOFs only happen at correct line boundaries) then you can seek to that byte position and continue
bkxd has joined #ruby
tdy has joined #ruby
asphyxia has joined #ruby
deathwishdave has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
asphyxia has quit [Ping timeout: 240 seconds]
kurko_ has joined #ruby
bkxd has quit [Read error: Connection reset by peer]
Dbugger has quit [Remote host closed the connection]
bkxd has joined #ruby
<phaul>
apeiros_: can you find derpy's code - if it's public?
<apeiros_>
didn't find it :( I'll try to contact adaedra
<phaul>
ok thanks
SeepingN has quit [Quit: The system is going down for reboot NOW!]
chouhoulis has quit [Remote host closed the connection]
<cthulchu>
phaul, I should remember the last byte and then start reading from there!
<cthulchu>
buz bytes are arrays, right?
<cthulchu>
I don't need to read through everything now!
<cthulchu>
only one problem: can Ruby tackle that?
Lytol has quit [Remote host closed the connection]
<havenwood>
cthulchu: You can't find the byte position of the end of a line without reading up to a newline.
<havenwood>
cthulchu: Files don't automagically know where newlines are.
<cthulchu>
that's fine
<cthulchu>
as I said, I read this file in iterations
<cthulchu>
I have, say, 20 tests running one after another
<phaul>
yeah what you are trying here would work.
<cthulchu>
logs from all of them get to the same file
<cthulchu>
but I don't need logs from test N 8 in test N 9
<cthulchu>
but now the question is even harder
<havenwood>
cthulchu: Above I showed an example of iterating through the file by line once, to find which offsets the newlines are located at. Then going through again, and reading between those offsets.
<cthulchu>
how do I save the byte position and load it to start iterating from there
<phaul>
cthulchu: IO#pos. IO#seek. IO#pos=
<cthulchu>
thanks
<cthulchu>
havenwood, I can't afford that and it's not very applicable
<phaul>
though I've never tried pos=, but seek to byte position should work
<cthulchu>
the problem is that I don't need seek to...
<cthulchu>
I need seek from
<cthulchu>
also seek is weird
<cthulchu>
I'm not sure how it works
<cthulchu>
I saw its doc
<havenwood>
cthulchu: Well, you've got to read through the file once to find the newlines. My example collects those points and uses #pread to read between them. You could read between them whenever you want, but you have to find the newlines if you want to seek to them.
<phaul>
cthulchu: seek gets you to a byte position.
<cthulchu>
but it seems to return 0
<cthulchu>
oh
<cthulchu>
and then what do I do with it?
<cthulchu>
do I just do file.each_line?
<cthulchu>
havenwood, I think I'll try seeking to byte #
<cthulchu>
I hope seek is smart enough to treat it as an array and not iterate through the thing
<havenwood>
cthulchu: My point is you can't see to the byte of a newline without reading the file to find where those bytes will be.
<cthulchu>
havenwood, I described above
<cthulchu>
havenwood, I read this file many times and don't want to start from 0 every time
<cthulchu>
phaul, will seek work for each_line?
evdubs_ is now known as evdubs
<phaul>
talking across purposes...
<phaul>
io.seek(100) will get you to byte position 100 (absolute position)
<cthulchu>
and then how do I iterate through new lines after that?
<cthulchu>
starting from that absolute position
<phaul>
I expect io.each_line { to work. let me check ...
<cthulchu>
or should I do that right in the each_line loop?
<phaul>
no you should seek first, then read the rest
<havenwood>
cthulchu: I showed an example of reading through once to find newlines without having the whole file in memory. You could then do the pread for each of those lines at any later point. I didn't show how to do it piecemeal, where you don't read through the whole thing but readline and continue, but that's not a far stretch from my example.
<cthulchu>
havenwood, it is useless since the file changes
<havenwood>
hahaha
<cthulchu>
I mean, the length of it. it's a log file
<cthulchu>
so I need to know the address since where to look for new changes
<cthulchu>
we figured it should be byte address, which makes perfect sense
<phaul>
cthulchu: yes I tried it works as expected
<cthulchu>
phaul, could you please show a snippet?