<cxl_>
Hey all, I'm a bit confused with require vs include... I have a short example here: https://dpaste.org/6Qgu, can you tell me which of the two examples I need?
<cxl_>
I think what I don't get is how to next a module within another when they're in different files.
<havenwood>
cxl_: Neither of those work, but include is closer. A require is simply loading Ruby code from another file, just it loads once.
<havenwood>
cxl_: While include is closer, it's for mixing in methods not changing namespace.
<havenwood>
cxl_: I'd suggest reading more about Ruby namespaces. Generally don't change `Bar::Baz` to be `Foo::Bar::Baz`, we'd define it under `Foo` to start with.
<cxl_>
My issue with this is that when I'm testing Foo::Bar::Baz, I require the file, and then everywhere in my test I have to call it Foo::Bar::Baz instead of more simply Bar::Baz or just Baz.
Jonopoly has joined #ruby
<adam12>
cxl_: That's natural in Ruby, but perhaps a bit different if you're used to Python
Aylat has quit [Quit: Leaving]
<cxl_>
adam12: Alright so it's not particularly frowned upon to use the full module "path" (Foo::Bar::Baz instead of Bar::Baz or Bas)?
<cxl_>
s/Bas/Baz
<adam12>
cxl_: No, and you won't always need to use it. If you're inside `Foo::Bar` already, you can just call `Baz`. Likewise, if you're in `Foo` already, you can call `Bar::Baz`.
<adam12>
cxl_: Ruby checks it's current namespace before looking outside. It does other things too for constant lookup (and I think there are some good Youtube videos about it if you want to deep dive), but in general, if you're inside something `X:Y`, you can access other things in `X:Y`, and you can leave off `X` if you're looking for something similar
<adam12>
to `X:Y` but maybe `X:Z`.
<adam12>
Not sure if that helps or is confusing :P
<adam12>
One thing to note, is that the _defining_ of X:Y:Z matters. If you just go class X:Y:Z, then you're not actually inside X:Y. You're still at the top level.
<cxl_>
adam12: Yes I get it. Always do `module A\n module B\n class C` rather than `class A::B::C`
<adam12>
cxl_: Yes. I'd say, at least until you're familiar with constant lookup. But I still do explicit namespaces 99% of the time.
<ysionneau>
as a first step, before cross compiling, I am trying to just replace the "gem build" using mkmf with the rake compile for native build. Then i'll try to cross compile using rake
gproto23 has quit [Remote host closed the connection]
oxfuxxx has quit [Ping timeout: 240 seconds]
<ysionneau>
hmm maybe I should just be doing "rake gem"
<nakilon>
pastebin is a cancer
oxfuxxx has joined #ruby
<rapha>
hi all
<rapha>
how are you all
<rapha>
is there something pre-made from extracting something like a schema from a deep hash? like, let's say, the hash is {book: {name: "weird stories"}, pages: [{number: 1, contents: "peter ate a leg"}, {number: 2, contents: "mary wasn't happy with that at all"}]}, then the "schema" would be {book: {name: String}, pages: [{number: Integer. contents: String}]} ...
<rapha>
s/from/for/
oxfuxxx has quit [Ping timeout: 256 seconds]
<adam12>
rapha: Maybe pattern matching on Ruby 3 (technically 2.7)
<rapha>
Oh some new Ruby for me to learn? Sign me up!
<rapha>
nakilon: nah, i really needed to derive a schema from (a very large amount of) input data. the above linked json-schema-generator did an awesome job, just don't count on it being very fast :)
roadie has quit [Ping timeout: 268 seconds]
<rapha>
also very nice video there :-D
<rapha>
man if that "cow" decided it didn't like the guy ... that'd be insta blood and gore
nullheroes has joined #ruby
<rapha>
and bookmarking your nakischema, that seems useful
<nakilon>
those cows are very kind )
ur5us has joined #ruby
oxfuxxx has quit [Ping timeout: 240 seconds]
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
roadie` has quit [Ping timeout: 268 seconds]
roadie` has joined #ruby
infinityfye has quit [Quit: Leaving]
Tasi has quit [Quit: Leaving]
<rapha>
don't tell me you own a couple of 'em :)
<rapha>
wow, SFI is still at 115
ur5us has quit [Ping timeout: 240 seconds]
___nick___ has joined #ruby
gcd has joined #ruby
howdoi has joined #ruby
szkl has quit [Quit: Connection closed for inactivity]
roadie` has quit [Ping timeout: 245 seconds]
roadie` has joined #ruby
ur5us has joined #ruby
oxfuxxx has joined #ruby
hololeap has quit [Remote host closed the connection]
hololeap has joined #ruby
roadie` has quit [Quit: ERC (IRC client for Emacs 25.3.50.1)]
oxfuxxx has quit [Ping timeout: 240 seconds]
roadie has joined #ruby
Spitfire_ is now known as Spitfire
___nick___ has quit [Ping timeout: 252 seconds]
<leah2>
is there a nicer way than case x in [:foo, *args] if !args.empty?; ...; end
<leah2>
irb 3.1 broke Ctrl-u -.-
<leah2>
and the completion is completely unreadable