adam12 changed the topic of #ruby to: Rules: https://ruby-community.com | Ruby 3.0.2, 2.7.4, 2.6.8: https://www.ruby-lang.org | Paste 4+ lines to: https://gist.github.com | Books: https://goo.gl/wpGhoQ
trillp has joined #ruby
trillp has quit [Remote host closed the connection]
michigan has joined #ruby
Rounin has quit [Ping timeout: 256 seconds]
factor1 has joined #ruby
factor has quit [Ping timeout: 260 seconds]
factor1 is now known as factor
mahlon has quit [Ping timeout: 268 seconds]
lad has joined #ruby
mahlon has joined #ruby
michigan has quit [Quit: Connection closed for inactivity]
pgib has joined #ruby
ur5us has quit [Ping timeout: 264 seconds]
lad has quit [Remote host closed the connection]
fusta has quit [Quit: Leaving]
jpw has joined #ruby
gr33n7007h has quit [Ping timeout: 268 seconds]
gr33n7007h has joined #ruby
gr33n7007h has quit [Ping timeout: 264 seconds]
vit has joined #ruby
gr33n7007h has joined #ruby
gr33n7007h has quit [Ping timeout: 268 seconds]
gr33n7007h has joined #ruby
gr33n7007h has quit [Ping timeout: 268 seconds]
gr33n7007h has joined #ruby
gr33n7007h has quit [Ping timeout: 256 seconds]
gr33n7007h has joined #ruby
gr33n7007h has quit [Read error: Connection reset by peer]
gr33n7007h has joined #ruby
jpw has quit [Remote host closed the connection]
gr33n7007h has quit [Ping timeout: 268 seconds]
gr33n7007h has joined #ruby
gr33n7007h has quit [Ping timeout: 268 seconds]
gr33n7007h has joined #ruby
gr33n7007h has quit [Ping timeout: 264 seconds]
gr33n7007h has joined #ruby
gr33n7007h has quit [Ping timeout: 268 seconds]
gr33n7007h has joined #ruby
gr33n7007h has quit [Ping timeout: 268 seconds]
gr33n7007h has joined #ruby
Rounin has joined #ruby
duds- has quit [Ping timeout: 276 seconds]
gr33n7007h has quit [Quit: WeeChat 3.3]
shokohsc8 has quit [Read error: Connection reset by peer]
shokohsc8 has joined #ruby
reset has quit [Quit: reset]
gr33n7007h has joined #ruby
kenichi has quit [Ping timeout: 260 seconds]
kenichi has joined #ruby
Busk has joined #ruby
trillp has joined #ruby
tempate has joined #ruby
duds- has joined #ruby
<tempate> I have an sorted array of numbers. Is there an elegant way to get all the elements below a certain value (which is not be in the array)?
Busk has quit [Quit: My computer has gone to sleep. ZZZzzz…]
gr33n7007h has quit [Ping timeout: 256 seconds]
gr33n7007h has joined #ruby
tempate has quit [Quit: Leaving.]
gr33n7007h has quit [Client Quit]
jetchisel has quit [Ping timeout: 268 seconds]
jetchisel has joined #ruby
duds- has quit [Ping timeout: 276 seconds]
Guest89 has joined #ruby
Guest89 has quit [Client Quit]
duds- has joined #ruby
duds- has quit [Ping timeout: 276 seconds]
leonthemisfit has quit [Ping timeout: 268 seconds]
tempate has joined #ruby
tempate has quit [Client Quit]
lunarkitty has quit [Quit: Connection closed for inactivity]
<adam12> tempate is gone, but I wonder if #partition would work.
<jhass[m]> I think partition iterates the entire array, so it's slightly less performant than bsearch_index + #[] in this case
<adam12> jhass[m]: I totally forgot about bsearch.
<jhass[m]> aww, you shouldn't, it's amazing for the few cases where it's useful :D
<adam12> Ruby is so damn awesome
<adam12> I wonder when the 3.1 preview is going to drop.
walidvb has joined #ruby
bastelfreak has quit [Quit: WeeChat 3.3]
<walidvb> hey all, just asked this on rubyonrails, but realize it's more of a ruby issue..
<walidvb> i created a class method that define_methods. That class method takes in a block. When that block is run, it seems to be run on the class, rather than the instance. Any clue? code => https://gist.github.com/walidvb/b02c7485bb2c9e578157ba5e55bd2c6f
<jhass[m]> Yes, unless you change it with instance_eval, blocks are called with their definition scope
<jhass[m]> in this simple example you could also simply forward the block to define_method, which also changes its execution scope
<walidvb> jhass[m] will look those up, thanks:)
<walidvb> which is cleaner, in your opinion?
<walidvb> ah, you mean therefore move the block down to the instance code
<jhass[m]> Personally I'm not a big fan of passing arguments through setting instance variables
<jhass[m]> especially in a metaprogramming context like this it can quickly become confusing IMO
bastelfreak has joined #ruby
<walidvb> i hear you. i need this to be generic, though.
<jhass[m]> but if you really just want your proc to be come a method body as is, just forwarding it as define_method's block argument certainly is the most succint
<walidvb> would you have a `*args` ?
<jhass[m]> probably, it's hard to judge without the full context :)
<walidvb> well, various mailers have a way to select templates, based on their variables(which i could of course pass to the `template_name` method)
<jhass[m]> doing define_method(:something, &some_lambda) should make the defined method gain the lambda's signature fwiw
<walidvb> some based on `@export`, others on `@user`, etc
<walidvb> aah ok think i got it
<walidvb> although this means i then need to pass the block to the call to `template_name`, no?
<walidvb> (i sorta liked the cleanliness of having the whole thing on one line, all contained within the `add_templates` call at the top of the class)
<jhass[m]> no, I don't follow why you'd need to pass any block at the call of the defined method
<walidvb> i'm not sure how you'd define it, then 🤔
Inline has joined #ruby
<jhass[m]> in your example you could do define_method(:template_name, &block) instead of what you're currently doing
<walidvb> if i `define_method(:foo, &bar)`, then i'd need to call `foo { my_block}`
<walidvb> ok lemme check
<walidvb> wait, is my last statement incorrect?
CrazyEddy has quit [Ping timeout: 260 seconds]
<jhass[m]> I think so
<jhass[m]> then if you make the lambda -> (export) { export.type } you'd need to call it with template_name(@export)
<walidvb> yeah i guess that's what i was trying to avoid.
<walidvb> hoping to make my main functions agnostic of how template_name is run (although you'll argue that they require instance vars to be set (@export in this case))
<jhass[m]> Yes, it's just an implicit dependency
Inline has quit [Quit: Leaving]
<walidvb> ended up going with `define_method(:foo, &block)`, but i'm not sure i understand how that became an instance call 🤔
<jhass[m]> it's just intrinsic behavior of how define_method treats its block argument
<walidvb> (and tbh the whole thing should work differently, to start with. atm i need the functions to be defined as this is how i grab the templates available to show to the user – wrong 😅)
<walidvb> > it's  just intrinsic behavior of how define_method treats its block argument
<walidvb> i'll have to take your word for it, and find time to read some more
<walidvb> thanks for your help!
Inline has joined #ruby
<jhass[m]> > This block is evaluated using instance_eval.
<jhass[m]> you're welcome
<walidvb> jhass[m]++
<walidvb> :)
leonthemisfit has joined #ruby
leonthemisfit has quit [Changing host]
leonthemisfit has joined #ruby
CrazyEddy has joined #ruby
walidvb has quit [Quit: Client closed]
pgib has quit [Quit: 00 PC LOAD LETTER]
_aeris_ has joined #ruby
aeris has quit [Ping timeout: 276 seconds]
_aeris_ is now known as aeris
ua_ has quit [Ping timeout: 268 seconds]
tkonto has joined #ruby
nemesit has joined #ruby
Busk has joined #ruby
tkonto has quit [Quit: tkonto]
Busk has quit [Ping timeout: 256 seconds]
tkonto has joined #ruby
Inline has quit [Ping timeout: 268 seconds]
gr33n7007h has joined #ruby
_ht has joined #ruby
gr33n7007h has quit [Ping timeout: 256 seconds]
reset has joined #ruby
___nick___ has joined #ruby
jpw has joined #ruby
fef has joined #ruby
___nick___ has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
___nick___ has joined #ruby
___nick___ has quit [Client Quit]
___nick___ has joined #ruby
fef has quit [Ping timeout: 276 seconds]
gr33n7007h has joined #ruby
shokohsc8 has quit [Quit: The Lounge - https://thelounge.chat]
ur5us has joined #ruby
dohtem has quit [Quit: Connection closed for inactivity]
ur5us has quit [Remote host closed the connection]
menace has joined #ruby
menace has quit [Changing host]
menace has joined #ruby
Inline has joined #ruby
shokohsc8 has joined #ruby
ur5us has joined #ruby
_axx0 has joined #ruby
KramerC has quit [Ping timeout: 245 seconds]
dostoyevsky2 has quit [Ping timeout: 268 seconds]
_axx has quit [Ping timeout: 260 seconds]
_axx0 is now known as _axx
dostoyevsky2 has joined #ruby
KramerC has joined #ruby
gr33n7007h has quit [Ping timeout: 256 seconds]
gr33n7007h has joined #ruby
shokohsc8 has quit [Quit: The Lounge - https://thelounge.chat]
dohtem has joined #ruby
_axx has quit [Quit: Ping timeout (120 seconds)]
_axx has joined #ruby
shokohsc8 has joined #ruby
ur5us has quit [Ping timeout: 260 seconds]
Guest32 has joined #ruby
Guest32 has quit [Client Quit]
hololeap has joined #ruby
jpw has quit [Remote host closed the connection]
ua_ has joined #ruby
___nick___ has quit [Ping timeout: 260 seconds]
m3ow1606 has joined #ruby
m3ow1606 has quit [Client Quit]
leonthemisfit has quit [Read error: Connection reset by peer]
leonthemisfit has joined #ruby
leonthemisfit has quit [Changing host]
leonthemisfit has joined #ruby
guardian has quit [Ping timeout: 268 seconds]
sam113102 has joined #ruby
wnd-conn has joined #ruby
sam113101 has quit [Remote host closed the connection]
sam113102 is now known as sam113101
danjo0 has joined #ruby
havenwood0 has joined #ruby
guardian has joined #ruby
ollysmith_ has joined #ruby
Ca1us has joined #ruby
dka_ has joined #ruby
FuraiTHD has joined #ruby
havenwood has quit [Read error: Connection reset by peer]
ollysmith has quit [Ping timeout: 246 seconds]
Caius has quit [Ping timeout: 246 seconds]
havenwood0 is now known as havenwood
alex[m]123 has quit [Ping timeout: 246 seconds]
sixecho has quit [Ping timeout: 246 seconds]
Furai has quit [Ping timeout: 246 seconds]
DEac-_ has joined #ruby
_ht has quit [Remote host closed the connection]
alex[m]1231 has joined #ruby
truc has joined #ruby
danjo has quit [Read error: Connection reset by peer]
danjo0 is now known as danjo
dka has quit [Ping timeout: 246 seconds]
bjonnh has quit [Ping timeout: 246 seconds]
DEac- has quit [Ping timeout: 246 seconds]
sixecho has joined #ruby
wnd has quit [Read error: Connection reset by peer]
leah2 has quit [Ping timeout: 264 seconds]
glider_ has quit [Ping timeout: 264 seconds]
leah2 has joined #ruby
duds- has joined #ruby
glider has joined #ruby
random-jellyfish has joined #ruby
pgib has joined #ruby
aeris has quit [Quit: ZNC - http://znc.sourceforge.net]
Liexei has quit [Ping timeout: 264 seconds]
hololeap has quit [Read error: Connection reset by peer]
aeris has joined #ruby
hololeap has joined #ruby
Liexei has joined #ruby
goldfish has joined #ruby
JSharp has quit [Ping timeout: 260 seconds]
JSharp has joined #ruby
guardian has quit [Ping timeout: 268 seconds]
goldfish has quit [Quit: Leaving]
guardian has joined #ruby
vit has quit [Ping timeout: 268 seconds]
work has joined #ruby
<work> Hello, how can I view all instance variables and instance methods of a class excluding the ones from parent class
teclator has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
goepsilongo has joined #ruby