<FromGitter>
<jrei:matrix.org> Yes and a bit less efficient
<FromGitter>
<syeopite:matrix.org> And more verbose than the if-block unfortunately.
<FromGitter>
<syeopite:matrix.org> Ooh haven't thought of that. Though that's only great for short keys; any longer then it gets pretty unreadable
<FromGitter>
<jrei:matrix.org> the if/eslif is good
<FromGitter>
<jrei:matrix.org> you can do as @naqvis said, but then you can't define a specific logic for each key
<FromGitter>
<syeopite:matrix.org> It works but it's quite verbose imo. Especially for longer chains like what Invidious often uses; being able to condense that into a case statement would be great
<FromGitter>
<naqvis> you are doing it right, but passed `data` is actually a json object, not a simple field. so you need to change `json.field "#{@options_key}"` to `json.object`
<FromGitter>
<syeopite:matrix.org> True. Haven't thought of that caveat
<FromGitter>
<skinnyjames> I think data in this case is a generate dstring
<FromGitter>
<skinnyjames> "{\"capabilities\":\"alwaysMatch\",\"browserName\":\"firefox\",\"moz:firefoxOptions\":\"{\\\"binary\\\":\\\"/usr/lib/firefox/firefox\\\"}\"}" is the result.. So the data is stringified twice. ⏎ ⏎ I tried to pass a String::Builder to the superclass but that results in infinite recursion
<FromGitter>
<naqvis> generated json in string format. as generated string would be something like `"binary": "blah blah blah"`
<FromGitter>
<skinnyjames> "{\"capabilities\":\"alwaysMatch\",\"browserName\":\"firefox\",\"moz:firefoxOptions\":\"{\\"binary\\":\\"/usr/lib/firefox/firefox\\"}\"}" is the result.. So the data is stringified twice. ⏎ ⏎ I tried to pass a String::Builder to the superclass but that results in infinite recursion
<FromGitter>
<Blacksmoke16> is that you doing `pp ob.json`?
<FromGitter>
<skinnyjames> ah, makes sense! thanks!
hightower2 has joined #crystal-lang
hightower2 has quit [Ping timeout: 245 seconds]
jhass[m] has quit [Ping timeout: 260 seconds]
jhass[m] has joined #crystal-lang
dostoyevsky2 has quit [Ping timeout: 252 seconds]
dostoyevsky2 has joined #crystal-lang
Volk has quit [Quit: See you next time!]
ur5us has joined #crystal-lang
kiwiroy has quit [Ping timeout: 240 seconds]
r0bby has quit [Ping timeout: 240 seconds]
kevinsjoberg has quit [Ping timeout: 260 seconds]
pusewic|away has quit [Ping timeout: 250 seconds]
Liothen has quit [Ping timeout: 250 seconds]
Liothen has joined #crystal-lang
r0bby has joined #crystal-lang
pusewic|away has joined #crystal-lang
kevinsjoberg has joined #crystal-lang
kiwiroy has joined #crystal-lang
Volk has joined #crystal-lang
Volk has quit [Changing host]
Volk has joined #crystal-lang
<FromGitter>
<plambert> I'm trying to read a CSV file that has a BOM (byte order mark) as the first three bytes. Even if I read the bytes off the IO before giving it to CSV, it seems to start at the beginning of the file. Any idea how I can either make it skip them, or keep it from rewinding before reading the headers?
<FromGitter>
<plambert> I can't find a `rewind` or `seek` in the CSV library code... but it still says the first quote is unexpectedly in the middle of the cell.
<FromGitter>
<plambert> Or maybe I can make an `IO::BOM` class that skips them and never lets the user seek over them... Hmmm...
<riza>
maybe that's incorrect documentation, but it seems to say you can type an array with the name of a module - A - and then shift instances of classes which include that module into the array
<FromGitter>
<Blacksmoke16> but thats now what you're doing
<FromGitter>
<Blacksmoke16> not*
<riza>
sure but if you can type an Array with it, why cant you type a variable with it
<riza>
A.class doesn't work -- it's not a class
<FromGitter>
<Blacksmoke16> it would work if you did `Bar.new(Foo.new)`
<FromGitter>
<Blacksmoke16> because it's expecting an instance of something that includes that type
<riza>
yep, but I don't see a way around that which isn't pivoting over to inheritance
<FromGitter>
<Blacksmoke16> depending on the use case, inheritance might make more sense. but hard to say w/o knowing the rest of the context of what you're wanting to do
<FromGitter>
<Blacksmoke16> sec, i have a better iea
<FromGitter>
<Blacksmoke16> idea
ur5us has quit [Ping timeout: 252 seconds]
<riza>
yeah, I don't think inheritance is a bad choice for me here. It boxes you in a bit where you can't inherit from other sources so I don't reach for it as my first goto
<riza>
that's an interesting approach...it feels a bit of a hack
<FromGitter>
<Blacksmoke16> the question i always ask myself when figuring out what to do: Do you want to support *both* structs and classes?
<FromGitter>
<Blacksmoke16> if the answer is yes, you need to use a module
<riza>
Hm, I don't think that's material in this case. I worry that I might need to subclass some unknown other class as well, and now I have multiple inheritance problems.
<FromGitter>
<Blacksmoke16> can you share more of what you're wanting to do?
<riza>
it's weird to me that `macro ItWorksClass` can be used as a type. I didn't expect that to work either
<FromGitter>
<Blacksmoke16> 🤔 thats prob bug
<riza>
hah
taupiqueur has quit [Ping timeout: 245 seconds]
<riza>
the goal is to provide an interoperability layer -- a Type which can be used to declare both static and instance methods, and I want to stash the Type in a config var so the library can dereference the Type with calls like Lib.interop.do_thing and Lib.interop.new(config).do_stuff
<riza>
I think for this case inheritance works fine, but I'm still surprised that there isn't a way to do this without
<riza>
sorry, i totally losttrack of time and have to run