havenwood changed the topic of #ruby to: Rules: https://ruby-community.com | Ruby 3.1.1, 3.0.3, 2.7.5: https://www.ruby-lang.org | Paste 4+ lines to: https://gist.github.com | Books: https://goo.gl/wpGhoQ
rhe has joined #ruby
m_antis has joined #ruby
roadie has joined #ruby
<mooff> is it using ractors?
ur5us has joined #ruby
ur5us_ has quit [Ping timeout: 240 seconds]
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 😅
<cxl> jhass[m]: that's what I meant: https://dpaste.org/rV33
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)
mbrndtgn has quit [Quit: The Lounge - https://thelounge.chat]
mbrndtgn has joined #ruby
<cxl> jhass[m]: thanks
infinityfye has joined #ruby
ollysmith has quit [Ping timeout: 272 seconds]
roadie has quit [Quit: ERC (IRC client for Emacs 25.3.50.1)]
szkl has quit [Quit: Connection closed for inactivity]
Tempesta has quit [Quit: See ya!]
infinityfye has quit [Quit: Leaving]
jetchisel has joined #ruby
roadie has joined #ruby
gr33n7007h has joined #ruby
jetchisel has quit [Ping timeout: 250 seconds]
jetchisel has joined #ruby
TCZ has quit [Quit: Leaving]
Tempesta has joined #ruby
Tempesta has quit [Client Quit]
fandre1986 has joined #ruby
<mooff> cxl: it might be helpful to see that classes are modules. that is, MyClass.is_a?(Class) == MyClass.is_a?(Module) == true
<mooff> and so they can be used for namespacing in the same way
<mooff> got another neat Symbol trick. i'm wondering if this might actually be usable
<mooff> :: Symbol.define_method(:|) { |obj| obj.method(self) }
<ruby-eval> => :|
<mooff> :: %w(/usr/* /var/*).map &:[] | Dir
<ruby-eval> => [["/usr/local"], ["/var/lib"]]
gproto23 has joined #ruby
wand has quit [Remote host closed the connection]
wand has joined #ruby
bit4bit has joined #ruby
TCZ has joined #ruby
szkl has joined #ruby
<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?
<jhass[m]> For me it renders really light somehow
<adam12> Oh. Damnit. I forgot to look at dark mode.
<jhass[m]> if I override with color: black in the input it renders fine 🤷
<adam12> jhass[m]: Thanks for catching.
<jhass[m]> <3
<jhass[m]> dark mode everything :D
<adam12> Mine is set to auto. I normally test manually but for gemdocs.org, it's a shoot-from-the-hip kind of project.
Tasi has quit [Ping timeout: 252 seconds]
jetchisel has quit [Ping timeout: 252 seconds]
jetchisel has joined #ruby
markong has joined #ruby
markong has quit [Quit: KVIrc 5.0.0 Aria http://www.kvirc.net/]
oxfuxxx has joined #ruby
oxfuxxx has quit [Ping timeout: 250 seconds]
oxfuxxx has joined #ruby
_ht has joined #ruby
mdemo has joined #ruby
jetchisel has quit [Ping timeout: 240 seconds]
duds- has quit [Ping timeout: 256 seconds]
duds- has joined #ruby
jetchisel has joined #ruby
Tasi has joined #ruby
roadie has quit [Quit: ERC (IRC client for Emacs 25.3.50.1)]
<axsuul> Hi is there a built-in ruby method (I recall with a new Ruby version) for determining the most common value in an array?
<adam12> axsuul: Enumerable#tally ?
<adam12> It's not the most common, but you could probably work it out from the max value.
<axsuul> Yep that's it, thanks!
<adam12> Actually, #max might work on it's own.
<adam12> >> ["baz", "foo", "bar", "foo"].max
<weaksauce> that won't work if baz was the most common it still returns foo since it's lexicographically maximal
RougeR has quit [Ping timeout: 252 seconds]
jetchisel has quit [Ping timeout: 256 seconds]
jetchisel has joined #ruby
jetchisel has quit [Ping timeout: 252 seconds]
jetchisel has joined #ruby
gproto23 has quit [Remote host closed the connection]
Tasi has quit [Ping timeout: 240 seconds]
<adam12> weaksauce: Oof. You're right. It works coincidentally.
_ht has quit [Remote host closed the connection]
Tasi has joined #ruby
robotmay has quit [Quit: No Ping reply in 180 seconds.]
robotmay has joined #ruby
jmcgnh has quit [Ping timeout: 272 seconds]
Tasi has quit [Ping timeout: 250 seconds]
jmcgnh has joined #ruby
szkl has quit [Quit: Connection closed for inactivity]
Tasi has joined #ruby
drincruz has quit [Ping timeout: 252 seconds]
jetchisel has quit [Ping timeout: 272 seconds]
jetchisel has joined #ruby
gfawcett1 has joined #ruby
Goodbye_Vincent4 has joined #ruby
rhe8 has joined #ruby
yuckey2d4 has joined #ruby
EvilAlan has joined #ruby
lucerne8 has joined #ruby
entropy has joined #ruby
Bitflux has joined #ruby
seabre_ has joined #ruby
dannyAAM_ has joined #ruby
cxl_ has joined #ruby
quintasan_ has joined #ruby
m_antis_ has joined #ruby
mahlon_ has joined #ruby
jimeh_ has joined #ruby
EvilAlan has quit [Quit: Client closed]
In0perable has joined #ruby
rhe has quit [*.net *.split]
m_antis has quit [*.net *.split]
cout has quit [*.net *.split]
cxl has quit [*.net *.split]
entropie has quit [*.net *.split]
pandabot has quit [*.net *.split]
seabre has quit [*.net *.split]
leftylink has quit [*.net *.split]
Inoperable has quit [*.net *.split]
jimeh has quit [*.net *.split]
Goodbye_Vincent has quit [*.net *.split]
Pixi has quit [*.net *.split]
Spitfire_ has quit [*.net *.split]
yuckey2d has quit [*.net *.split]
apotheon has quit [*.net *.split]
mahlon has quit [*.net *.split]
quintasan has quit [*.net *.split]
dannyAAM has quit [*.net *.split]
Byteflux has quit [*.net *.split]
lucerne has quit [*.net *.split]
gfawcett has quit [*.net *.split]
rhe8 is now known as rhe
entropy is now known as entropie
dannyAAM_ is now known as dannyAAM
yuckey2d4 is now known as yuckey2d
Goodbye_Vincent4 is now known as Goodbye_Vincent
lucerne8 is now known as lucerne
gfawcett1 is now known as gfawcett
jetchisel has quit [Ping timeout: 252 seconds]
jimeh_ is now known as jimeh
jetchisel has joined #ruby
EvilAlan has joined #ruby
leftylink has joined #ruby
Pixi has joined #ruby
apotheon has joined #ruby
Spitfire_ has joined #ruby
cout has joined #ruby
pandabot has joined #ruby
Artea- has quit [Quit: ZNC 1.6.2 - http://znc.in]
drincruz has joined #ruby
Tasi has quit [Ping timeout: 240 seconds]
EvilAlan has quit [Quit: Client closed]
jetchisel has quit [Ping timeout: 240 seconds]
jetchisel has joined #ruby
jetchisel has quit [Max SendQ exceeded]
jetchisel has joined #ruby
jetchisel has quit [Max SendQ exceeded]
jetchisel has joined #ruby
EvilAlan has joined #ruby
jetchisel has quit [Max SendQ exceeded]
jetchisel has joined #ruby
roadie has joined #ruby
jetchisel has quit [Max SendQ exceeded]
jetchisel has joined #ruby
jetchisel has quit [Max SendQ exceeded]
jetchisel has joined #ruby
jetchisel has quit [Max SendQ exceeded]
jetchisel has joined #ruby
jetchisel has quit [Max SendQ exceeded]
jetchisel has joined #ruby
jetchisel has quit [Max SendQ exceeded]
jetchisel has joined #ruby
jetchisel has quit [Max SendQ exceeded]
EvilAlan has quit [Quit: Client closed]
jetchisel has joined #ruby
jetchisel has quit [Max SendQ exceeded]
jetchisel has joined #ruby
Tasi has joined #ruby
jetchisel has quit [Ping timeout: 272 seconds]
nemesit has quit [Ping timeout: 250 seconds]
kaleido has quit [Remote host closed the connection]
vvmt0 has joined #ruby
kaleido has joined #ruby
jetchisel has joined #ruby
roadie has quit [Ping timeout: 272 seconds]
vvmt0 has left #ruby [WeeChat 3.4]