<en10n>
Was thinking I could use a method from Enumerable to drill into it, but am not having any success getting beyond just returning the full instance of the class object.
<en10n>
Also, apologies if I'm not describing this in the correct vernacular. I'm new, trying to learn more.
pandakekok9 has quit [Ping timeout: 260 seconds]
alfiemax has quit [Remote host closed the connection]
cnsvc has joined #ruby
jinmiaoluo has quit [Ping timeout: 250 seconds]
jinmiaoluo has joined #ruby
pandakekok9 has joined #ruby
burgestrand has quit [Quit: burgestrand]
<jhass>
en10n: what do you want cheapest to return, an instance of a Product or the name field inside that Product?
<jhass>
the given answer should work for the latter, maybe you changed your test code from what you posted in the question in the mean time?
<en10n>
@jhass Thanks for the reply. The latter, the name field inside the Product.
<en10n>
@jhass When I tried the suggested code, I was getting a NoMethodError for "name".
<jhass>
which shouldn't happen in case your test code is unaltered from the one in the question
<en10n>
I will double-check.
careta has quit [Ping timeout: 256 seconds]
<jhass>
or maybe you have more tests than you showed?
<jhass>
lot's of guessing here :D
<en10n>
@jhass Yes, I see that is exactly the issue. The error is from another test. Thank you very much for helping me figure that out.
cnsvc has quit [Ping timeout: 240 seconds]
<jhass>
always good to double check the backtrace going through the code you think the error is coming from :)
drincruz has quit [Read error: Connection reset by peer]
cliluw has quit [Ping timeout: 256 seconds]
fanta1 has joined #ruby
drincruz has joined #ruby
akem has joined #ruby
akem has quit [Max SendQ exceeded]
akem has joined #ruby
Emmanuel_Chanel has quit [Quit: Leaving]
brool has joined #ruby
conta has joined #ruby
Emmanuel_Chanel has joined #ruby
SuperLag has joined #ruby
alfiemax has joined #ruby
SuperL4g has quit [Ping timeout: 240 seconds]
TCZ has quit [Quit: Leaving]
TCZ has joined #ruby
TCZ has quit [Remote host closed the connection]
TCZ has joined #ruby
jinmiaoluo has quit [Ping timeout: 265 seconds]
aesthe has joined #ruby
burningserenity has quit [Remote host closed the connection]
rippa has joined #ruby
<jhass>
honestly I don't like the whole idea
ritalinona has quit [Ping timeout: 240 seconds]
Ai9zO5AP has quit [Ping timeout: 240 seconds]
iNs_ has quit [Ping timeout: 240 seconds]
_aeris_ has quit [Ping timeout: 240 seconds]
leitz has joined #ruby
hassox has joined #ruby
ellcs has joined #ruby
hassox has quit [Ping timeout: 264 seconds]
fercell has quit [Quit: WeeChat 2.8]
<apotheon>
Is "endless methods" some kind of reference to the idea of defining methods without the "end" keyword?
<al2o3-cr>
apotheon: yes.
_aeris_ has joined #ruby
Ai9zO5AP has joined #ruby
iNs has joined #ruby
ritalinona has joined #ruby
kinduff has quit [Read error: Connection reset by peer]
kinduff has joined #ruby
<apotheon>
I see.
<apotheon>
I'm not entirely enthused by the idea so far, but so far that's all I know about the idea.
<apotheon>
al2o3-cr: Thanks.
<al2o3-cr>
apotheon: np :)
<leitz>
I'm enthused, the half-dozen "end" statements looks odd. To me, anyway. That's why I use {} where possible.
<leitz>
That, and vim matches for me, when I get lost...
hassox has joined #ruby
lucasb has joined #ruby
<apotheon>
I do wish Vim would match end using %, but otherwise I think that for any multiline method definition using end is better than braces.
hassox has quit [Remote host closed the connection]
<apotheon>
(or other multiline blocks of code, in the non-Ruby sense of a block of code)
<apotheon>
What do we call a block of code that isn't a Ruby block? I'm still not sure, after fifteen years of familiarity with Ruby.
<apotheon>
A conditional block, a class definition, a ruby definition, and a Ruby block are all examples of that superset of the non-Ruby-terminology block.
<apotheon>
s/ruby definition/method definition/
<apotheon>
not sure how I typed "ruby" there
<leitz>
If a yaml and json file are built from the same data (Using perl), and then slurped into Ruby, how do I find the differences? There seems to be a lot of them, but the hashes seem similar from a surface level. https://gist.github.com/LeamHall/9a6d6f80f5a56a67d35552279be81540
<leitz>
apothon, I found myself typing "exit" when I meant something totally different, the other night. I took that as a sign for a nap. :)
<apotheon>
oops
Ai9zO5AP has quit [Ping timeout: 240 seconds]
al2o3-cr has quit [Quit: WeeChat 2.8]
<apotheon>
In addition to not liking multiline brace-enclosed blocks, I wonder what happened to your indentation on that File.open.
<leitz>
apotheon, and, how are you doing today?
<apotheon>
I didn't get enough sleep.
<apotheon>
Something woke me up early, and I didn't get back to sleep. My brain is probably full of failure today.
<leitz>
I had that problem the other night. I took yesterday easy...
al2o3-cr has joined #ruby
conta has quit [Read error: Connection reset by peer]
<apotheon>
So . . . I think you need to sort your keys before performing the == test.
conta has joined #ruby
<apotheon>
. . . if you want a "true" result.
<leitz>
I thought hashes compared out of order?
<apotheon>
I don't recall.
<apotheon>
Oh, yeah, that's right, they do.
<apotheon>
hmm
fercell has joined #ruby
<apotheon>
erm
TCZ has quit [Quit: Leaving]
<leitz>
I get ~1700 differences if I compare them.
TCZ has joined #ruby
<apotheon>
You might try comparing a sorted list of keys first to see if there's a difference, then (if not) iterating over a sorted list of values.
<apotheon>
. . . or key-value pairs.
<apotheon>
wow
alfiemax has quit [Remote host closed the connection]
<apotheon>
Did you say this was the same data?
<apotheon>
(initially)
<apotheon>
I might not understand what you're trying to do. I wouldn't want to have to sift through 1700 identified differences.
<leitz>
Yup. And the keys are the same, it looks like. Line 23 has no output.
<leitz>
Half the time I don't understand what I'm trying to do...
<apotheon>
same initial data, turned by Perl's serialization and Ruby's deserialization into different data
<apotheon>
That seems awful.
<apotheon>
It might be worth trying different JSON and YAML libs to see if one of the libraries you used is buggy.
<apotheon>
f'rinstance, I wonder if Syck produces the same hash as Psych with your data
burningserenity has joined #ruby
alfiemax has joined #ruby
sergioro has joined #ruby
TCZ has quit [Quit: Leaving]
gitter1234 has joined #ruby
Xiti` has joined #ruby
SeepingN has joined #ruby
Ai9zO5AP has joined #ruby
<leitz>
Okay...looks like it's stupid. One version quotes a 0 and another doesn't. That level of difference, since "0" is a string in ruby, and 0 is not.
<leitz>
That was the first error I found, there are likely others.
Xiti has quit [Ping timeout: 260 seconds]
Xiti` has quit [Max SendQ exceeded]
Xiti` has joined #ruby
alfiemax_ has joined #ruby
Xiti` has quit [Max SendQ exceeded]
Xiti` has joined #ruby
Xiti` has quit [Read error: Connection reset by peer]
d3bug has quit [Quit: Connection closed for inactivity]
<apotheon>
Perl should differentiate between numbers and numeric strings, too, though in practice it doesn't feel like it does.
<apotheon>
Does JSON not differentiate between strings and numbers as datums? I don't recall.
Xiti has quit [Ping timeout: 256 seconds]
<apotheon>
ah
alfiemax_ has quit [Ping timeout: 256 seconds]
<apotheon>
I just checked. Apparently, JSON is supposed to differentiate.
<apotheon>
. . . so there's definitely a bug somewhere.
Xiti` has quit [Ping timeout: 256 seconds]
<apotheon>
In YAML, I know that unquoted numeric strings are actually just numbers, and not strings (though quoted numeric strings *are* actual string data).
cnsvc has quit [Ping timeout: 240 seconds]
ellcs has quit [Ping timeout: 256 seconds]
Esa__ has joined #ruby
arekushi has quit [Quit: Gateway shutdown]
jinmiaoluo has joined #ruby
SeepingN has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
alfiemax has joined #ruby
ChmEarl has joined #ruby
cthu| has joined #ruby
alfiemax has quit [Remote host closed the connection]
imode has joined #ruby
cd has joined #ruby
TomyWork has quit [Remote host closed the connection]
hiroaki has joined #ruby
cnsvc has joined #ruby
vondruch has quit [Ping timeout: 250 seconds]
SeepingN has joined #ruby
Xiti has joined #ruby
<SeepingN>
as should always be
Pixi__ has quit [Ping timeout: 256 seconds]
fanta1 has quit [Quit: fanta1]
Xiti has quit [Read error: Connection reset by peer]
Xiti has joined #ruby
<leitz>
Perl tends to transmute, behind the scenes, IIUC.
schne1der has quit [Ping timeout: 264 seconds]
conta has quit [Quit: conta]
<phaul>
apotheon: nvim matches ends with %, for normal vim you need pkgadd! matchit (which ships with vim anyway)
<apotheon>
phaul: I see. I don't use any plugins for Vim, so I hadn't noticed it shipped with that.
<apotheon>
I'm not sure what you mean by "pkgadd!" though.
rikkipitt has quit [Remote host closed the connection]
rikkipitt has joined #ruby
rikkipitt has quit [Remote host closed the connection]
rikkipitt has joined #ruby
rikkipitt has quit [Remote host closed the connection]
rikkipitt has joined #ruby
rikkipitt has quit [Read error: Connection reset by peer]
rikkipitt has joined #ruby
rikkipitt has quit [Remote host closed the connection]
rikkipitt has joined #ruby
rikkipitt has quit [Remote host closed the connection]
ldepandis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Pixi__ has quit [Quit: Leaving]
ur5us has quit [Read error: Connection reset by peer]
ur5us has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.8]
d3bug has quit [Quit: Connection closed for inactivity]
<deimos_>
i think i'm not understanding something with sequel gem and postgres. I thought DB[:table2].import([:field2], DB[:table1].distinct(:field1)) equals "INSERT INTO table2 ("field2") SELECT DISTINCT field1 FROM table1" what am I missing?
<deimos_>
the db returns an error, "Sequel::DatabaseError (PG::SyntaxError: ERROR: INSERT has more expressions than target columns)"
<deimos_>
it appears Sequel puts a * in the DISTINCT statement
<deimos_>
which causes all 30 columns of table1 to be returned
ellcs has quit [Ping timeout: 256 seconds]
<deimos_>
the raw sql runs and completes fine without error
m27frogy has quit [Read error: Connection reset by peer]
TCZ has quit [Quit: Leaving]
cahoots has quit [Ping timeout: 265 seconds]
<deimos_>
DB.run "raw sql here" just works too
rmnull has joined #ruby
cd has quit [Quit: cd]
schne1der has quit [Ping timeout: 258 seconds]
troulouliou_dev has quit [Quit: Leaving]
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
sergioro has quit [Quit: Lost terminal]
sergioro has joined #ruby
Xiti has joined #ruby
rmnull has quit [Ping timeout: 272 seconds]
drincruz has quit [Ping timeout: 240 seconds]
m27frogy has joined #ruby
Ai9zO5AP has quit [Ping timeout: 240 seconds]
alexherbo2 has quit [Remote host closed the connection]
<adam12>
deimos_: Don't forget there's a #sequel channel too.
<adam12>
deimos_: DB[:table1].distinct.select(:field1) will get you want you want if you're looking to use the Sequel builder syntax.
Ai9zO5AP has joined #ruby
m27frogy has quit [Read error: Connection reset by peer]