Sheilong has quit [Quit: Connection closed for inactivity]
<havenwood>
mooff: Nope, defers to Rack webserver to handle the spec but no Ractor dep.
<mooff>
ah... what's the purpose of the .freeze s ?
<mooff>
i assumed it was ractor related
<havenwood>
mooff: They're not needed for the example, but Roda got me on freezing my Rack apps.
<havenwood>
It'll occasionally surface a thread safety issue.
<mooff>
interesting
<havenwood>
In this app just not needed. I like it generally
hanzo has joined #ruby
eddof13 has joined #ruby
roadie has quit [Ping timeout: 250 seconds]
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
eddof13 has joined #ruby
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
donofrio has quit [Read error: Connection reset by peer]
jetchisel has quit [Ping timeout: 256 seconds]
jetchisel has joined #ruby
swaggboi has quit [Quit: C-x C-c]
swaggboi has joined #ruby
Rounin has quit [Ping timeout: 256 seconds]
ur5us has quit [Ping timeout: 240 seconds]
hanzo has quit [Quit: Connection closed for inactivity]
mooff has quit [Remote host closed the connection]
mooff has joined #ruby
ur5us has joined #ruby
ur5us has quit [Remote host closed the connection]
ur5us has joined #ruby
RedNifre has quit [Ping timeout: 256 seconds]
EvilAlan has joined #ruby
RedNifre has joined #ruby
ur5us has quit [Ping timeout: 272 seconds]
rando25892 has joined #ruby
EvilAlan has quit [Quit: Client closed]
EvilAlan has joined #ruby
eddof13 has joined #ruby
peer8 has joined #ruby
peer has quit [Ping timeout: 252 seconds]
peer8 is now known as peer
roadie has joined #ruby
ur5us has joined #ruby
EvilAlan has quit [Quit: Client closed]
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
guest1 has joined #ruby
guest1 has quit [Quit: WeeChat 3.4]
teclator has joined #ruby
<nakilon>
is "binding.of_caller" smth new?
<nakilon>
ah, a gem
jetchisel has quit [Ping timeout: 240 seconds]
EvilAlan has joined #ruby
EvilAlan has quit [Quit: Client closed]
Rounin has joined #ruby
justAstache4 has joined #ruby
justAstache has quit [Ping timeout: 256 seconds]
justAstache4 is now known as justAstache
ur5us has quit [Read error: Connection reset by peer]
jetchisel has joined #ruby
gr33n7007h has quit [Ping timeout: 272 seconds]
andrea[m] has quit [Quit: You have been kicked for being idle]
<ox1eef>
quite an old gem, too
jetchisel has quit [Ping timeout: 240 seconds]
roadie has quit [Ping timeout: 252 seconds]
TCZ has joined #ruby
roadie has joined #ruby
roadie has quit [Ping timeout: 245 seconds]
<cxl>
Hi all, I'm having a hard time understanding the difference between "#" and "::" when reading documentation. In the official Ruby docs, for the CSV module for instance, some methods are documented under "CSV::open", and others as "CSV#each". What does it mean?
roadie has joined #ruby
<jhass[m]>
cxl: :: denotes that the method is called on the class itself. Foo::bar -> Foo.bar. # denotes that the method is called on an instance of the class Foo#bar -> Foo.new.bar
<cxl>
jhass[m]: Hmmm, ok... so it means that the :: method is defined in the module but # is defined in the class?
<jhass[m]>
mmh, I think you got it right but I can't quite submit to that phrasing due to various reasons 😅
whysthatso1250 has quit [Quit: Ping timeout (120 seconds)]
whysthatso1250 has joined #ruby
<jhass[m]>
Ah, no, those would both be Foo#meth_one and Bar#meth_two respectively, because you call neither as Foo.meth_one nor Bar.meth_two. You need an instance of Foo or Bar respectively to call them and thus they are denoted with #
<cxl>
What would it look like then for a Foo#meth_one and a Foo::meth_two? What would the class/module look like?
<cxl>
or is that not the way to tell
hololeap has quit [Remote host closed the connection]
<jhass[m]>
the typical way to define a Foo::bar would be module/class Foo; def self.bar; end; end;
<cxl>
Oh ok, it's about the self. or its absence. So :: is a class method and # is an instance method, basically
<jhass[m]>
But I think the important fact that :: vs # in the docs is trying to convey is not how they are defined but how to call them
<jhass[m]>
yeah, more than basically, that's exactly it
hololeap has joined #ruby
<cxl>
Right, so if it has a # you have to call new first, but if it's :: you can call it without instantiating
<jhass[m]>
Yep
<cxl>
Got it, thanks. Now I'm wondering: what's the point of mixing class methods and instance methods in the same namespace?
<jhass[m]>
Now on a technical level that distinction doesn't exist, def self.bar is just a shortcut syntax to define an instance method on self's singleton class, but don't worry about that for now :)
Tasi has joined #ruby
<cxl>
I also see it's possible to have a class in a class. Is that because you can't define methods on a module? So if you need a parent class with methods and another class inside it with its own methods, you do a class in a class? I'm looking at https://github.com/ruby/ruby/blob/ruby_2_7/lib/csv/row.rb for example.
<cxl>
Nah, you can define self. methods on a module... So I don't get it.
<jhass[m]>
the point of mixing is just that it's convenient. Given Ruby doesn't have method overloads a common usecase for example is to provide additional constructors or helpers for interacting. Consider File.new vs File.open for example. Or in the CSV example you have different ways of reading the data which may or may not create you an instance of CSV or so
<jhass[m]>
In Ruby classes are essentially a specialization of modules, so a class is literally a specialization of a module. Modules are what act as namespaces and collections of method definitions, a class then just adds the functionality of creating an object/instance for the type
<jhass[m]>
the other specialization of a class compared to a module is around inheritance. While modules are added to the inheritance via include and a child module (or class, remember all classes are modules) may have any number of direct "ancestor" modules, a class can only act as a parent class and have one parent class (in addition to any ancestor modules)
<adam12>
I wish the documentation was updated to use the new dot-style syntax for calling class methods.
<adam12>
I wonder if there's been pushback or nobody has ever bothered.
<sam113101>
adam12: is it new?
<adam12>
sam113101: So, it's not new as in recent. But very very old versions of Ruby used more :: style calls (I think they are C style calls IIRC).
<adam12>
Eventually the community standardized on dot notation for class methods.
<adam12>
But this "standardization" feels like it's been forever. 2005 at least? If I go back in memory, I can't remember if I ever did CGI::h or similar.
<jhass[m]>
fwiw yard renders dot or nothing at all depending on context
<adam12>
Adding search to gemdocs.org. Not serving 800kb of gems in a <ul> anymore. Heh.
bit4bit has quit [Ping timeout: 256 seconds]
teclator has quit [Ping timeout: 256 seconds]
hresco3 has quit [Ping timeout: 256 seconds]
teclator has joined #ruby
hresco3 has joined #ruby
fandre1986 has quit [Quit: Connection closed]
<skandal>
Hello. How i can extend products.erb by base.erb ?
<adam12>
skandal: extend as in Django style {% extend %}?
TCZ has quit [Quit: Leaving]
<jhass[m]>
adam12: that input could use a color: black; or something though 😅
<adam12>
jhass[m]: What color is it for you? It's _almost_ black for me. Not enough contrast?