xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Garb0 has joined #ruby
romanlevin has quit [Ping timeout: 272 seconds]
d3bug has joined #ruby
dandaman has joined #ruby
orbyt_ has joined #ruby
<dandaman>
hi all. I have a class function that returns an object of the instance but with some added keys… I'm not sure how to do this with ruby though. Can someone take a look at this gist and let me know what the proper syntax should be? https://gist.github.com/dsauerbrun/5dfc7d122182f23872cd2865de3b31a3
<dandaman>
do i just need to do my_ret_val = {} and just map all of the class properties? that seems tedious :(
<havenwood>
dandaman: I don't follow your example.
<havenwood>
dandaman: self.respond_to?(:[]=)
<havenwood>
dandaman: So you're saying #[]= is defined or what are you getting at here?
<havenwood>
dandaman: Say what you want to do another way? Or say why? Or show real code?
<dandaman>
ok, i'll show the real code, one moment
<dandaman>
compare to how i'm doing it in the method in line 142 of old.rb
<dandaman>
basically i'm sending a json friendly version of the object to an endpoint, but there are some properties I want to send along with that object for the endpoint such as grades, accommodations, etc… which are related datum
ldepandis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<dandaman>
thank you leftylink
drincruz has joined #ruby
ChmEarl has quit [Quit: Leaving]
ChmEarl has joined #ruby
monter has joined #ruby
cnsvc has quit [Ping timeout: 240 seconds]
dandaman has quit [Quit: Leaving.]
cliluw has quit [Ping timeout: 264 seconds]
monter has quit [Quit: This computer has gone to sleep]
mikecmpbll has quit [Quit: inabit. zz.]
cnsvc has joined #ruby
cliluw has joined #ruby
cnsvc has quit [Ping timeout: 240 seconds]
monter has joined #ruby
DTZUZU has quit [Quit: WeeChat 2.7]
schne1der has quit [Ping timeout: 246 seconds]
monter has quit [Quit: Leaving]
monter76 has joined #ruby
Vashy has quit [Ping timeout: 252 seconds]
cnsvc has joined #ruby
Vashy has joined #ruby
cnsvc has quit [Ping timeout: 240 seconds]
<monter76>
Hi. I'd like to view the all the old messages on the server to see some cool ruby snippets and such. I'm not sure how to do this, I'm new to IRC. Are the logs for this channel, or for free node channels in general, stored anywhere? I checked https://freenode.logbot.info/?q=ruby and https://echelog.com/
drincruz has quit [Ping timeout: 246 seconds]
<adam12>
monter76: I don't believe this channel is logged.
<xco>
my client logged me off and i couldn't get anything that came after
<havenwood>
[17:11:57] <havenwood>: xc, Was afk. Yup!
<havenwood>
xco: Yes, exactly.
<havenwood>
xco: It's along the same lines as a default order.
<xco>
havenwood awesome. everything makes sense now then
<xco>
or even #reorder
<havenwood>
xco: It's considered a bit more of an anti-pattern to have a default order. Yup, exactly—#reorder.
<xco>
it saves you writing another scope i'll guess
<xco>
if you're lazy or just won't use that scope much
<havenwood>
and if there's a default scope, it saves you from backbending to undo it.
<havenwood>
it's not a super common occurrence, but it happens enough for the #re# methods to exist.
<xco>
havenwood personsally i haven't seen it used anywhere before!
<havenwood>
xco: I agree the examples look odd!
<havenwood>
xco: I see reorder more often.
<havenwood>
More often than rewhere.
ellcs has quit [Ping timeout: 260 seconds]
<havenwood>
xco: #rewhere is rare.
<havenwood>
xco: If you have a cloud server floating around somewhere, it might be worth setting up ZNC for automatic log replay when you reconnect.
<havenwood>
xco: IRC is nicer with ZNC.
<xco>
havenwood on your comment "the examples look odd!" is the same problem Avdi was talking about recently...that a lot of then things in Rails are meant for the experts, costing Rails some contributors, now i sort of know what he meant but that's more philosophical than anything
<havenwood>
xco: Ruby is meant for expert C programmers and Rails is meant for expert webapp developers. ¯\_(ツ)_/¯ Nobody realized!
<xco>
havenwood i was reading about ZNC yesterday, then I saw " IRC bouncer" and immediately stopped reading haha.. Bouncer??? what's that supposed to mean?
<havenwood>
xco: Sometimes it's worth catering to experts but giving a ramp for beginners. Larry Wall has spoken eloquently on this topic.
<havenwood>
xco: An IRC bouncer logs onto IRC for you then you log onto it instead of the IRC server and it bounces you the messages.
<xco>
"Ruby is meant for expert C programmers"<< this i noticed rather years ago!!! and i can agree to this "Rails is meant for expert webapp developers."
<havenwood>
xco: Who is Matz? An expert C programmer. Who is DHH? An expert webapp developer. They made them for themselves, so it checks out.
<havenwood>
xco: A bouncer is basically like if IRC replayed everything you missed whenever you reconnect.
<havenwood>
xco: It's a bit annoying to set up but well worth it.
<havenwood>
Set up once, enjoy for years.
<xco>
the images in that link make friendlier
<xco>
it*
rmnull has joined #ruby
rmnull has quit [Client Quit]
<adam12>
Another reasonable alternative is IRCCloud.
sergioro has joined #ruby
drincruz has joined #ruby
ldepandis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
drincruz has quit [Ping timeout: 258 seconds]
FastJack has quit [Ping timeout: 256 seconds]
<xco>
+1
FastJack has joined #ruby
<xco>
i know about this ['Cat', 'Dog', 'Bird'].include?('Unicorn')
<xco>
=> false
<xco>
I just learned about this one
<xco>
'Unicorn'.in?(['Cat', 'Dog', 'Bird'])
<xco>
=> false
<havenwood>
xco: Rails, not Ruby. :)
<xco>
didn't know such a thing existed hahaha
<havenwood>
xco: It doesn't in Ruby!
<xco>
holy shit!
<havenwood>
It's been proposed.
<xco>
you're right!
<xco>
well... if it's been proposed and ignored i can understand it
<xco>
#include? is enough i'd think
<xco>
I don't know what #include? can't do that #in? would do
<havenwood>
xco: Matz agrees
<xco>
really?
<xco>
when should we expect it then? any plans you know of?
<havenwood>
xco: I mean he agrees it's redundant and unnecessary.
<xco>
hahahha
<xco>
rightly so!
<xco>
for me it would be shorter to type but that's not important
<xco>
we shouldn't add redundant things
<xco>
and i just read "There is an in? method in ActiveSupport (part of Rails) since v3.1, as pointed out by"
<xco>
i would have been surprised i still don't know this in Ruby after all this while... i don't know a lot of things in Ruby still though but THIS i would have jumped out of my balcony
<xco>
but sometimes it's hard to know where AS ends and where Ruby start or vice versa
<xco>
not that i'm irritated by it, but it's annoying when tech companies want to test you on that
<xco>
that would mean knowing Ruby or Rails in its entirety to be able to know what doesn't belong in one
<xco>
:D :D
<xco>
which is not possible unless you're Matz
ropeney has quit [Ping timeout: 256 seconds]
<havenwood>
xco: I learned Ruby for years before touching Rails, so I know by exclusion.
<xco>
EDIT: which is not possible unless you're Matz or havenwood or adam12 or phaul or al2o3-cr
<xco>
havenwood for those years this you work with just Ruby? without any framework? that'd be some hard core stuff then
ldepandis has joined #ruby
<havenwood>
xco: Sinatra apps and APIs for mobile and embedded devices mostly. Nothing too hardcore, but some of the embedded project APIs were fun. Got a few patents and sold the startup to Scientific Games.
<havenwood>
xco: I considered Rails more challenging!
alexherbo2 has quit [Quit: Ping timeout (120 seconds)]
alexherbo2 has joined #ruby
ropeney has joined #ruby
lxsameer has quit [Ping timeout: 260 seconds]
<xco>
nice! i was thinking you did Ruby without frameworks. because apparently a lot of people use Rails even for the simplest APIs which i find overkill
<xco>
for apis i can agree Sinatra and even Hanami API are just fine
<havenwood>
xco: I switched from Sinatra to Roda at some point.
Xiti` has joined #ruby
<havenwood>
xco: My first brush with Rails was writing a Sinatra API for a mobile app against a Rails DB. :O
Pixi__ has joined #ruby
<xco>
havenwood that's quite common, i've seen the Sinatara api against Rails done a few times
<havenwood>
The mobile team had a very specific, but moving target that was onerous for the Rails team at the time. I wouldn't do it the same today, but it worked well.
Xiti has quit [Ping timeout: 240 seconds]
<havenwood>
xco: I did non-web Ruby without frameworks too. It seems simpler to me when web isn't involved though—not more complex.
<xco>
but good experiences i guess, now you're well-versed on both the small (Sinatra) and big (Rails) frameworks and the language that connects them (Ruby). before i got into Rails some book (i don't remember) advised me to learn Sinatra first (which I did) before coming to Rails. After a few months i had mastered Sinatra... after years I still haven't mastered Rails and have forgotten almost all my Sinatra!
Xiti` has quit [Ping timeout: 240 seconds]
alexherbo2 has quit [Ping timeout: 246 seconds]
<havenwood>
xco: Coding is such a large surface area you can't help but get niche expertise.
<havenwood>
Impossible to learn it all.
lxsameer has joined #ruby
<havenwood>
Which is lovely, since there's no need to switch fields when you get bored.
<xco>
you just pick another language/framework then
<xco>
agree
<havenwood>
after bird law, I ran out of options
<havenwood>
xco: or security, ops, system programming, data science, so much
cliluw has quit [Ping timeout: 260 seconds]
<havenwood>
xco: or even in Ruby stuff like telephony, networking, machine learning, and whatever else can all be explored.
gitter1234 has quit [Quit: Connection closed for inactivity]
<havenwood>
I tried to match Enumerable#lazy behavior but with #memoized.
ChmEarl has joined #ruby
Garb0 has joined #ruby
schne1der has quit [Ping timeout: 272 seconds]
plutes has quit [Ping timeout: 256 seconds]
plutes has joined #ruby
s2013 has joined #ruby
imjoehaines has quit [Remote host closed the connection]
conta has joined #ruby
alexherbo25 has joined #ruby
orbyt_ has joined #ruby
oneeggeach has joined #ruby
oneeggeach has quit [Client Quit]
kinduff has quit [Read error: Connection reset by peer]
alexherbo2 has joined #ruby
kinduff has joined #ruby
alexherbo25 has quit [Ping timeout: 264 seconds]
<xco>
havenwood i see something i'd like to ask about though... and i read about it but forgot. the rails on L26 will raise INTERRUPT again correct? why are you doing that?
chouhoulis has joined #ruby
<havenwood>
xco: It's fine for it to raise, it just needs to rewind first so it doesn't get left in a transient state.
<havenwood>
xco: The interrupt is meant to happen.
<havenwood>
xco: I should comment but it's just a code spike.
cliluw has joined #ruby
<xco>
got it
Rakko has joined #ruby
chouhoulis has quit [Ping timeout: 256 seconds]
wymillerlinux has quit [Remote host closed the connection]
drincruz has joined #ruby
wymillerlinux_ has joined #ruby
sergioro has quit [Quit: leaving]
troulouliou_dev has quit [Read error: Connection reset by peer]
sergioro has joined #ruby
cliluw has quit [Ping timeout: 244 seconds]
cliluw has joined #ruby
drincruz has quit [Ping timeout: 264 seconds]
sergioro has quit [Quit: leaving]
chalkmonster has quit [Quit: WeeChat 2.8]
sergioro has joined #ruby
chalkmonster has joined #ruby
chalkmonster has quit [Client Quit]
<xco>
what are some of the techniques to safely override Ruby core functionality apart from "refinements"?
Rakko has quit [Quit: Leaving]
<xco>
buy "safely" i mean overriding functionality in a way that a method doesn't seep all the way to the intepreter as a general method
<xco>
by* (you get it)
<havenwood>
xco: You can `unless respond_to?(:foo); def foo(...)` but it's overbearing and something that only behemoths like Rails can get away with.
<havenwood>
xco: Refinements are really the way to lexically monkey patch, if you want to keep your footprint sane.
<havenwood>
xco: Otherwise, use a function rather than opening a core class for modification.
<havenwood>
I think it's fair to say *never* define a method on a core class, unless you do so with a refinement these days.
schne1der has joined #ruby
<xco>
how about overriding the method on a per object basis? would that be sane?
<xco>
something along the lines of def object.length; ... end
<havenwood>
xco: Yes, there are cases where you define a method on an instance of object, or that sort of thing. That doesn't leak and become insidious when others do it too.
<havenwood>
xco: "Define singleton method" is just too broad.
<xco>
single method = a method defined in the eigenclass of an object
<havenwood>
xco: eigenclass and singleton class are the same thing.
<xco>
yes... so a singleton method here is a method defined in the singleton class of an object :)
<havenwood>
xco: Core classes are objects though, so you can get into trouble defining singleton methods on them.
<xco>
hmmm
<havenwood>
I'm just saying it's not safe to define singleton methods as a general rule. Sometime.
<havenwood>
You can define methods on objects you've created.
<havenwood>
That *seems* like a fairly safe statement to me.
<havenwood>
If you create a class or instance of a class, define away.
<havenwood>
If the object already exists, I'd say it seems messy to define a method on it.
<havenwood>
Someone else could too, then... chaos.
<xco>
that's leaves refinements as the only way then
<havenwood>
Matz wouldn't have rocked the boat hard enough to create them if there was a good alternative.
<xco>
aside someone else overriding your override would it be safe then? just assuming...
<havenwood>
xco: if you don't override an existing method to make yours work, how does yours work?
markopasha has joined #ruby
<havenwood>
you can have a fallback, but uhg. it gets messy fast.
<havenwood>
xco: It's kinda fine for a *single* player to do this, like Rails does. Everyone else in the ecosystem has to refrain. You see some Rails gems also monkey patch core classes, but it's mostly Rails that does it.
<havenwood>
Rails was written before refinements exist, too.
<havenwood>
xco: I've had great luck using refinements with Rails. They *just work*.
<havenwood>
And no ensuing chaos.
<xco>
right
renich has joined #ruby
<havenwood>
My only gripe is them not working by default at top level in irb and Pry.
<xco>
there's a reason refinements are module-scoped
<havenwood>
They work in irb at top level if you set: IRB.conf[:CONTEXT_MODE] = 0
<havenwood>
I'd actually like the default :CONTEXT_MODE to be changed from 3 to 0.
<xco>
i haven't seen CONTEXT_MODE mode before
<xco>
what does it do?
<xco>
CONTEXT_MODE (number): Sets the type of binding that irb uses when evaluating statements. Can be either 0, 1, 2 or 3 (3 is the default).
alexherbo2 has quit [Ping timeout: 256 seconds]
markopasha has quit [Quit: WeeChat 2.8]
Garb0 has quit [Quit: Leaving]
conta has quit [Quit: conta]
inguz has joined #ruby
jeromelanteri has joined #ruby
<havenwood>
xco: It's about where the TOPLEVEL_BINDING is going to be in. With 3 it's a function. With 0 it's a proc.
<havenwood>
xco: 1 is a tempfile. I can't remember what 2 is.
<NGC3982>
hi. when i run ruby --version it tells me 2.7.0p0, but when i run "sudo gem install lita" i get "ERROR: Error installing lita: bundler requires Ruby version >= 2.3.0"
<NGC3982>
any suggestions? it seems like i havent properly upgraded ruby ..i guess?
<NGC3982>
gem env tells me that GEM PATHS are /home/henrik/.rvm/gems/ruby-2.7.0
<al2o3-cr>
havenwood: now i remember how i did it ;)
<al2o3-cr>
Pry.hooks.add_hook(:when_started, 'context_switch') { |_, _, pry| pry.binding_stack << TOPLEVEL_BINDING } # add this to ~/.pryrc
<al2o3-cr>
that'll drop you into the top level binding. just cd to escape ;)
<al2o3-cr>
well, adds it to the binding stack.
<al2o3-cr>
^ havenwood:
cnsvc has quit [Ping timeout: 240 seconds]
<al2o3-cr>
that's from booting my other thinkpad and looking at my .pryrc, although i used before_session then.
blackmesa1 has joined #ruby
blackmesa has quit [Ping timeout: 260 seconds]
<adam12>
NGC3982: sudo normally strips some environment variables and resets others. PATH can be one of tem. If you're using rvm, often it's user specific.
<adam12>
NGC3982: That said, you might not need `sudo` when running gem here.
ellcs has quit [Ping timeout: 256 seconds]
tubbo is now known as tubbo|afk
tubbo|afk is now known as tubbo
seaef has quit [Quit: I am functioning within established parameters.]
conta has quit [Quit: conta]
goepsilongo has joined #ruby
blackmesa1 has quit [Ping timeout: 260 seconds]
<havenwood>
NGC3982: `rvmsudo` is an RVM command or RVM has "wrappers" that set env.
<havenwood>
NGC3982: See `rvmsudo --help` and `rvm help wrapper`.
<havenwood>
NGC3982: Both will preserve relevant env.
rapha has left #ruby ["WeeChat 2.3"]
cnsvc has joined #ruby
woodruffw has quit [Excess Flood]
woodruffw has joined #ruby
cnsvc has quit [Ping timeout: 240 seconds]
ellcs has joined #ruby
schne1der has quit [Remote host closed the connection]
tubbo is now known as tubbo|afk
tomg has quit [Quit: Leaving]
tomg has joined #ruby
tubbo|afk is now known as tubbo
ellcs has quit [Ping timeout: 256 seconds]
woodruffw has quit [Ping timeout: 258 seconds]
<hodbogi>
I never thought I'd have to cover my engine compartment with fire retardant.
<hodbogi>
wrong window...
<apotheon>
That's an amusing non-sequitur here.
<hodbogi>
yeah my carburetor likes to breathe fire and I started it up before cleaning up all of the gas that leaked all over the engine
<apotheon>
oops
<apotheon>
Don't, uh, *do* that.
<apotheon>
Why is your carburetor breathing fire?
<hodbogi>
I think the timing is way too advanced. its either that or the valves aren't seating properly so the spark is causing an explosion that shoots ouit of the carburetor
<apotheon>
(That actually kinda sounds like Firefox. JavaScript is basically combining fuel and oxygen for injection of fire into the rendering engine, resulting in the kind of user experience that leaves one feeling burned.)
<hodbogi>
lol
<hodbogi>
it's a 1967 big block V8 its going to have some wear and tear
<apotheon>
ooh
<hodbogi>
I got it because of the pandemic and something to work on
<hodbogi>
keep me busy
<apotheon>
Chevelle?
<hodbogi>
no, it's for a 24,000 pound truck
<apotheon>
ah
<hodbogi>
but its very similar to the engine they used in the cars its just the block walls are thicker so they can take more abuse
<apotheon>
I like overengineered engines like that.
<hodbogi>
yeah its nice, and aside from blocks and stuff the heads and valves and shafts and everything are interchangable
<apotheon>
I have a 1987 Toyota SR5 4x4 pickup, and it's just a four-banger, but it's the sort of overengineered design that it'll still be functional 25 years after the apocalypse.
<hodbogi>
heh
<apotheon>
s/that it'll/that'll/
<hodbogi>
this is a Ford F-700
<apotheon>
old enough to be worth maintaining
<hodbogi>
I don't have much experience with fords but the parts are everywhere
<apotheon>
My experience with Fords after 1980 is full of distaste.
<apotheon>
The stick shifts seem prone to developing roughness and general shittiness after a couple years or so, and the automatics I've driven are just miserable to use (speaking of Fords with model years after 1980).
tubbo is now known as tubbo|afk
<apotheon>
I should uninstall Rails turbolinks from my motorcycle.
<apotheon>
(Watch me smoothly transition back to Ruby talk.)
<havenwood>
apotheon: I thought you were going to segue on engine block. :)
<apotheon>
good idea
<apotheon>
damn
kinduff has quit [Read error: Connection reset by peer]
kinduff has joined #ruby
d3bug has joined #ruby
ritalinona has quit [Quit: bleep]
tubbo|afk is now known as tubbo
<hodbogi>
apottheon: The transmission in this truck is pretty decent. It's a 5 speed and the differential is two speed so I essentially have 10 gears
<hodbogi>
in a way
<hodbogi>
in 1 low it will go like 5 miles per hour at 7000 rpm or so