<adam12>
musashi: That's one thing I like about Unpoly. Built in modals :P
Thanzex5 has joined #ruby
Thanzex has quit [Ping timeout: 264 seconds]
Thanzex5 is now known as Thanzex
crankharder has joined #ruby
<arfy>
hmmm. can someone point me in the right direction here? I had a script that I wrote under ruby 2.5.1, which used the form "processing #file". When I picked up the script again recently under ruby's 2.6.8 and 3.12, that syntax didn't work. so when was that form of string interpolation removed?
desnudopenguino has quit [Read error: Connection reset by peer]
desnudopenguino has joined #ruby
TomyWork has joined #ruby
jpn has joined #ruby
desnudopenguino has quit [Read error: Connection reset by peer]
desnudopenguino has joined #ruby
taiju has quit [Ping timeout: 255 seconds]
Mikaela has quit [Remote host closed the connection]
jpn has quit [Ping timeout: 240 seconds]
jl- has joined #ruby
jl- has quit [Ping timeout: 276 seconds]
moldorcoder7 has joined #ruby
jpn has joined #ruby
jpn has quit [Ping timeout: 244 seconds]
jpn has joined #ruby
markong has joined #ruby
crankharder has joined #ruby
jpn has quit [Ping timeout: 268 seconds]
crankharder has quit [Ping timeout: 244 seconds]
nirvdrum has joined #ruby
infinityfye has quit [Quit: Leaving]
Zerock has joined #ruby
<Zerock>
Where can I find all the methods of the Socket class? I see the official documentation, but the example code lists a "puts" method that doesn't appear in the doc. I'm tried looking in super- and subclasses to no avail. I assume it's mixing in a module, but it isn't clear which one.
<Zerock>
My actual goal is to figure out whether a socket has data to receive. I want to check whether I need to process something without blocking the thread.
<jhass[m]>
Zerock: Socket < BasicSocket and BasicSocket < IO, which is where put's is coming from. To get a true total list I like to just fire up a REPL (irb, pry), get an instance of the object and looks at .methods.sort or so
<Zerock>
oh somehow I missed IO
<Zerock>
and yes, .methods would work but I wanted to read a description as well
<Zerock>
Thanks for that. Do you happen to also know the answer to my specific socket question? .recvfrom_nonblock looks promising but it's not entirely clear to me how it works
<Zerock>
ideally there would be something to just return a boolean for whether there is coming data
<jhass[m]>
.method(:something).owner usually gives you the type it's coming from
<jhass[m]>
I'd probably try IO#read_nonblock
taiju has joined #ruby
<jhass[m]>
Maybe you have some luck with IO#ready?
<jhass[m]>
but IME it's all very hit and miss
<Zerock>
hmmm, I see example code under read_nonblock for using .select to wait for data
<Zerock>
I'll look at ready
<jhass[m]>
safest probably is to just have a seperate thread reading your socket in a busy loop, do some basic message splitting and push events to a Queue which your main thread listens to
<Zerock>
jhass[m]: That is the plan once my connection is fully established. I was hoping to keep it simple for the initial handshake sequence.
<Zerock>
but yeah maybe I just need to jump straight into the loop
<jhass[m]>
because behavior of all of this changes between the underlying thing being a TCP socket, UDP socket, File handle, Pipe, Block device etc. and then if opened with O_NONBLOCK or not, using event APIs or regular stuff and so on
<jhass[m]>
my point is doing a coherent IO abstraction is basically impossible
<Zerock>
well luckily in my case this application will only use TCP sockets, so it would at least be consistent in that respect
jl- has joined #ruby
protektwar has joined #ruby
protektwar has quit [Changing host]
protektwar has joined #ruby
protektwar has quit [Client Quit]
protektwar has joined #ruby
protektwar has quit [Changing host]
protektwar has joined #ruby
jpn has joined #ruby
jl- has quit [Ping timeout: 272 seconds]
Ziyan_ has joined #ruby
<Zerock>
One unrelated thing... I know I can turn a method into a block using something like &method(:my_method) if the method is in the current scope. How would I do a similar contruct if the method is a member of some other module or class?
Ziyan has quit [Ping timeout: 268 seconds]
Mikaela has joined #ruby
jpn has quit [Ping timeout: 268 seconds]
<jhass[m]>
it works for "current scope" because it's just a method call, so think foo(&self.method(:my_method)); or to be even more verbose method_obj = self.method(:my_method); foo(&method_obj)
<jhass[m]>
Now you're in no way limited to calling method on self only, you can call it on any scope
<jhass[m]>
er, object
<Zerock>
And this works for modules as well?
<jhass[m]>
kinda yes
<Zerock>
neat
<jhass[m]>
all methods in Ruby are actually instance methods, so you need always some object, some "self" for the method to run with
<Zerock>
right, but modules have a self
<jhass[m]>
.method takes care of this by binding the object it's called itself upon to the returned method object
<jhass[m]>
so if you're talking about an instance method in a module, you'll need to call it on some object (=instance of some class) that has the module included
<Zerock>
that makes sense
<Zerock>
I just ran a quick test and it's behaving as I'd expect. Thanks. :)
<jhass[m]>
if you're talking about a "class method"/"module function"/"singleton method", something you'd regularly call as MyModule.my_method, MyModule.method(:my_method) works fine because there the object is the instance of Module assigned to the constant MyModule
jpn has joined #ruby
<Zerock>
right, yep
<jhass[m]>
cool, cheers
<Zerock>
call .method of whatever object I need it from, and that object might be a class or module itself
_aeris_ has joined #ruby
taiju[m] has joined #ruby
Ziyan_ has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
crankharder has joined #ruby
Ziyan has joined #ruby
crankharder has quit [Ping timeout: 268 seconds]
Thanzex5 has joined #ruby
Thanzex has quit [Ping timeout: 240 seconds]
Thanzex5 is now known as Thanzex
incal has left #ruby [ERC 5.4.1 (IRC client for GNU Emacs 29.0.50)]
jpn has quit [Ping timeout: 268 seconds]
moldorcoder7 has quit [Ping timeout: 268 seconds]
moldorcoder7 has joined #ruby
Mikaela is now known as Aminda
lus3Rz has joined #ruby
lus3Rz has quit [Remote host closed the connection]
lus3Rz has joined #ruby
crankharder has joined #ruby
lus3Rz has quit [Remote host closed the connection]
jpn has joined #ruby
jpn has quit [Ping timeout: 240 seconds]
crankharder has quit [Quit: leaving]
Ziyan_ has joined #ruby
Ziyan has quit [Ping timeout: 272 seconds]
jpn has joined #ruby
protektwar has quit [Ping timeout: 255 seconds]
jpn has quit [Ping timeout: 268 seconds]
bit4bit has joined #ruby
jpn has joined #ruby
jl- has joined #ruby
Thanzex has quit [Ping timeout: 268 seconds]
jl- has quit [Ping timeout: 240 seconds]
<Zerock>
I'm trying to add an exception handler for SIGINT. I see that it causes an Interrupt, but when I try to rescue Interrupt, it doesn't seem to actually capture it. I see that I can handle it using trap(), but I want to be able to access some local variables in my handler. what's going on?
sgt_chuckles has joined #ruby
taiju has quit [Ping timeout: 240 seconds]
<Zerock>
oh, I've got it. If I try to do with by just writing a test block into stdin of ruby, it doesn't work, but if it's in a file, it does
Aminda has quit [Ping timeout: 268 seconds]
Aminda has joined #ruby
<sgt_chuckles>
I have an rspec with multiple repetitive definitions I want to condense into a single reusable function.
<sgt_chuckles>
thing is, the difference with each of these repetitive blocks is the object which uses a different method for each definition
<sgt_chuckles>
wondering if theres a way to somehow pass a function to it???
<cAMP>
Assuming one has 3 different sizes of World grid (line 42), what would be a good way to express this, and how to best calculate the resulting spread of values? Something with ranges perhaps?
<cAMP>
ATM on line 51 there is just the medium sized world for the calcs.
<musashi>
HAT-P-7b, the exoplanet that contains clouds of vaporized ruby
Wilbur8 has joined #ruby
jl- has joined #ruby
Linux_Kerio has quit [Ping timeout: 272 seconds]
jpn has quit [Ping timeout: 240 seconds]
aeris has quit [Remote host closed the connection]
aeris has joined #ruby
kristianpaul has joined #ruby
<kristianpaul>
o/
<kristianpaul>
Do you know of other pkcs7 implementation outside openssl's?
<Zerock>
I have a class with a hash which I would like to map from strings to other classes. These other classes are subclasses of this class. When I try to initialize this hash, I get a NameError because those other classes are defined further down the file. What am I doing wrong?
<cAMP>
declare classes before attempting to use them?
<Zerock>
I can't declare a subclass without first declaring the superclass...
Wilbur8 has quit [Ping timeout: 268 seconds]
<cAMP>
Seem to me you think other than what you have implemented.
<cAMP>
In any case, next step in irc debug would be a link to a pastebin or gist
Aminda has quit [Remote host closed the connection]
Aminda has quit [Remote host closed the connection]
Aminda has joined #ruby
<weaksauce>
a simple way but probably need to rethink your design in all honesty would be to declare stub classes at the top of your module and then reopen them later
<Zerock>
yeah that's ugly
<cAMP>
Maybe instead of inheritance, attempt to use mix-in approach.
<Zerock>
hmmm
<Zerock>
there's an idea
dionysus69 has joined #ruby
twosuns has joined #ruby
musashi has quit [Quit: leaving]
jpn has joined #ruby
<Zerock>
What is this... I have a class Foo with a class method self.bar that I want to pass in to another method as a block. I tried &Foo.method(:bar) but I'm getting a TypeError: no implicit conversion of Method into Array
<Zerock>
why does it think I'm trying to convert to an array?
<Zerock>
if it matters, the method to which I'm trying to pass it looks like: def my_method(arg, &block)