havenwood changed the topic of #ruby to: Rules: https://ruby-community.com | Ruby 3.2.0, 3.1.3, 3.0.5, 2.7.7: https://www.ruby-lang.org | Paste 4+ lines to: https://gist.github.com | Books: https://t.ly/9ua4 | Logs: https://libera.irclog.whitequark.org/ruby/
<neshpion> # %w(thing.mov thing.mp4 thing.avi thing.webm).sort_by { |s| %w(avi mp4 webm).index { |ext| s.include? ext } || 0 }.reverse
Laplace has quit [Quit: Connection closed for inactivity]
<neshpion> s/reverse/last
<weaksauce> just one match?
<weaksauce> or first match of the priority
<neshpion> first of priority, or whatever happens to be at the end of the list if none of the priorities are matched
<neshpion> meaning the highest priority pattern needs to have the highest index
<weaksauce> yeah
<weaksauce> i see
<weaksauce> clever? maybe... but just going through the list once and keeping track of the first index of each might be most performant / easiest
<weaksauce> hash keys have been ordered since ruby 1.9 so you could use that fact
<weaksauce> and use reduce with an object
<weaksauce> s/object/hash
Averna has quit [Ping timeout: 252 seconds]
Synthead has joined #ruby
<ox1eef_> I probably don't understand the requirements, but based on the description you gave, maybe: %w(foo.mpg bar.avi).find { %w(.mpg avi).one? { File.extname(filename) } }
<ox1eef_> %w(foo.mpg bar.avi).find { |filename| %w(.mpg .avi).one? { |extname| extname == File.extname(filename) } } *
<weaksauce> they want best first find ox1eef_
<weaksauce> so say avi is their preferred codec they want that first
<weaksauce> even if there is a mp4 in the list before it
<ox1eef_> Ah I see
cartdrige has joined #ruby
<ox1eef_> %w(.avi .mpg).find { |extname| break %w(foo.mpg bar.avi).find { |file| File.extname(file) == extname } }
<ox1eef_> Time to eat Christmas dinner. That might be something to work with.
<ox1eef_> %w(.avi .mpg).find could be %w(.avi .mpg).each as well.
markong has quit [Ping timeout: 272 seconds]
desnudopenguino has joined #ruby
neshpion has quit [Remote host closed the connection]
neshpion has joined #ruby
cartdrige has quit [Quit: I am more peaced off than a dragon trying to blow out candles]
neshpion has quit [Ping timeout: 255 seconds]
neshpion has joined #ruby
Synthead has quit [Ping timeout: 248 seconds]
<neshpion> i landed on `filenames.max_by { |f| extensions.index { |ext| f.end_with? ext } || 0 }`
reset has quit [Quit: reset]
c10l5 has quit [Quit: See ya! o/]
c10l5 has joined #ruby
c10l5 has quit [Quit: See ya! o/]
c10l5 has joined #ruby
c10l5 has quit [Client Quit]
c10l5 has joined #ruby
Laplace has joined #ruby
Synthead has joined #ruby
Sheilong has quit []
neshpion has quit [Quit: neshpion]
desnudopenguino1 has joined #ruby
desnudopenguino has quit [Ping timeout: 260 seconds]
desnudopenguino1 is now known as desnudopenguino
desnudopenguino has quit [Ping timeout: 252 seconds]
desnudopenguino has joined #ruby
desnudopenguino has quit [Ping timeout: 255 seconds]
Synthead has quit [Quit: Leaving]
Laplace has quit [Quit: Connection closed for inactivity]
cryptkeeper has joined #ruby
FullMetalStacker has joined #ruby
FullMetalStacker has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
John_Ivan_ has joined #ruby
M1ll173r47[m]1 has quit [Quit: You have been kicked for being idle]
John_Ivan has quit [Ping timeout: 260 seconds]
jvalleroy has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
jvalleroy has joined #ruby
Sankalp has quit [Ping timeout: 268 seconds]
cryptkeeper has quit [Quit: Connection closed for inactivity]
Sankalp has joined #ruby
cartdrige has joined #ruby
gr33n7001 has joined #ruby
gr33n7007h has quit [Killed (zirconium.libera.chat (Nickname regained by services))]
gr33n7001 is now known as gr33n7007h
Guest1673 has joined #ruby
rvalue has quit [Quit: ZNC - https://znc.in]
hightower2 has quit [Ping timeout: 248 seconds]
aeris has quit [Remote host closed the connection]
tomtmym has joined #ruby
tomtmym has quit [Changing host]
tomtmym has joined #ruby
aeris has joined #ruby
ollysmith has quit [Quit: ZNC 1.8.2+deb3+b3 - https://znc.in]
ollysmith has joined #ruby
<petru> Ugh, jekyll doesn't work with 3.2 because of shopify/liquid gem
hightower2 has joined #ruby
hightower2 has quit [Remote host closed the connection]
hightower2 has joined #ruby
<Rounin> petru: If it's not something you're using, is it possible that you could make your own shopify/liquid gem that doesn't do anything?
<Rounin> If it's just a matter of having something that has the same name and returns...
hightower2 has quit [Remote host closed the connection]
<Rounin> Of course, if it always tries to get the gem online, that's an issue
<Rounin> What can I say, I work in integration... It's 90% duck tape and stopgap solutions there
cartdrige has quit [Quit: I am more peaced off than a dragon trying to blow out candles]
sixpiece has joined #ruby
<sixpiece> hi anyone know how to use ruby for rest api?
<joto> sixpiece, consuming or creating?
<sixpiece> I want to do it on the line for now I think
<sixpiece> cause I am so new to it
<sixpiece> but if you have another idea I would try that
<sixpiece> interactive ruby irb , just to get familiar and then go from there was my thought
<joto> ok so I assume you want to consume a rest api
<joto> in that case: look up the httparty gem
<joto> that would be the easiest
hightower2 has joined #ruby
rvalue has joined #ruby
perrierjouet has joined #ruby
perrierjouet has quit [Quit: WeeChat 3.7.1]
nmollerup has joined #ruby
hightower2 has quit [Remote host closed the connection]
cartdrige has joined #ruby
hightower2 has joined #ruby
reset has joined #ruby
crax23 has joined #ruby
cartdrige has quit [Ping timeout: 265 seconds]
reset has quit [Quit: reset]
reset has joined #ruby
markong has joined #ruby
ox1eef_ has quit [Quit: WeeChat 3.7]
ox1eef_ has joined #ruby
markong has quit [Ping timeout: 260 seconds]
cryptkeeper has joined #ruby
gr33n7007h has quit [Quit: WeeChat 3.7.1]
hightower2 has quit [Remote host closed the connection]
hightower2 has joined #ruby
hightower2 has quit [Ping timeout: 272 seconds]
goldfish has joined #ruby
sixpiece has quit [Ping timeout: 268 seconds]
hightower2 has joined #ruby
aeris has quit [Read error: Connection reset by peer]
Mikaela has quit [Write error: Connection reset by peer]
aeris has joined #ruby
Mikaela has joined #ruby
Mikaela has quit [Remote host closed the connection]
Mikaela has joined #ruby
ua_ has quit [Ping timeout: 246 seconds]
ua_ has joined #ruby
cryptkeeper has quit [Quit: Connection closed for inactivity]
entropie has quit [Ping timeout: 265 seconds]
entropie has joined #ruby
goldfish has quit [Quit: Leaving]
markong has joined #ruby
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
r3m has quit [Quit: WeeChat 3.8-dev]
r3m has joined #ruby
tomtmym has quit [Quit: Gone.]
_ht has joined #ruby
crax23 has quit [Ping timeout: 264 seconds]
desnudopenguino has joined #ruby
_ht has quit [Quit: _ht]