#ruby - 13 November 2018
« Back 1 day Forward 1 day »
[05:54:35] hays: I guess I can define ==, but this means I need to make the internals public.. which isn't a bad thing per se, but just want to make sure im headed in the right direction here
[05:58:19] hays: am i correct that i'lll need to be able to make this determination through public accessors
[05:59:22] havenwood: hays: You might consider also defining #eql? and #=== for your custom class, if those make sense.
[06:04:27] havenwood: hays: you can use meta-programming to get at private methods, when that makes sense
[06:05:58] havenwood: hays: yes, that's where you also might define #eql?, since: 1.eql?(1.0) #=> false
[06:06:33] havenwood: hays: you can #send if #a is private or get the instance method if there's no method at all.
[06:06:49] hays: but how does 1==1.0 work? it seems like your Integer needs to know the structural internals of your Float
[06:09:53] havenwood: hays: #to_int is a special conversion just for this case, slightly different from #to_i
[06:10:28] havenwood: hays: === is for case statements, and predicate enumerable methods, and other such implicit use
[06:22:54] hays: but maybe its ok, speaking more broadly, I might have Dog.to_i, that returns some sort of Dog id
[06:24:05] hays: whereas the Float/Int thing is maybe a bit hazier, in terms of one just being a more precise, or different repressentation of the other
[06:27:54] hays: i came across pondering this question in a way where i have to compare two big fat json objects, and there's a lot of logic involved in how to compare the different members, right now i have a big fat block of conditional code that does the job, but was thinking of ways to clean it up
[06:32:13] hays: i think the right way to do it would be to JSON.parse it, then go through it and replace the raw string/int/float data with objects of appropriate type. that way comparsons would work right and be encapsulated in the classes to which they belong
[06:57:27] hays: or I guess to_json(*a, &b), although im not really sure i understand what it does with those
[07:06:43] hays: hmm. the ruby source code itself, i see (1) to_json with no args (2) to_json with *a or similar 3) to_json with just *
[18:03:22] orbyt_: Company office network has been having a strange issue when attempting to connect to rubygems. For whatever reason, it the connection will timeout, but making the network service inactive and then re-enabling it (macOS) seems to briefly resolve the issue.
[18:03:30] orbyt_: Does anyone have a clue as to what might be going on? The internet works fine, it's just rubygems
[18:58:48] z64: hey all - i'm having some trouble making a simple pure ruby native extension. i have looked at docs and some example repos, and have `ext/mkrf_conf.rb` added to `s.extensions` & `s.files` but it does not seem to be executing
[19:01:10] z64: the `mkrf_conf.rb` is suppoed to install some dependencies after doing some environment checks. nothing gets installed with `bundle install`, or even something like a `puts` is not displayed
[19:44:19] z64: ah nevermind i think.. it just isn't installed when running from within the gem repo itself. creating a quick dummy project with a Gemfile, bundle install builds the extension. maybe i just need to add running the ext/mkrf_conf.rb script to our dev rakefile then?
[20:16:34] ben: I'm a bit lost with gemfiles and gemspecs and some half-packaged scripts floating around my machine :)
[21:16:43] ivanskie: i'm having an annoying issue of "WARN: Unresolved specs during Gem::Specification.reset"
[21:17:19] ivanskie: i've done `gem clean` and removed only the gems mentioned in the warning. and this is still popping up (standalone ruby project)
[21:17:50] ivanskie: maybe i should google some more. but the suggestions from what I have found, don't seem to help
[21:40:20] ivanskie: i'm putting together a TTY based gem (with thor).. and i thought i'd use awesome_print for easier to read output for logging.
[21:40:38] ivanskie: and then was refactoring Gemfile into gemspec for the gem. and since bundle clean --force.. it broke it somehow
[21:41:11] ivanskie: it adds .ap method to Logger class. and this used to work. and now it doesn't i don't get it.
[23:44:53] relyks: Radar: for any method? but preferably one that's not in the standard library? i'm curious how you go about handling all exceptions that might result from someone else's code
[23:48:00] relyks: Radar: so there isn't a way without actually observing what exceptions are produced? nothing like calling .methods on an object to see its available methods?
[23:48:43] Radar: relyks: Exceptions could happen for many, many different reasons. Maybe it's a timeout because it failed to connect to a HTTP endpoint? But maybe it's an ArgumentError because of a typo in the code. It's hard to predict exceptions. They are exceptional.
[23:49:37] relyks: yeah, true, but perhaps a method throws specific exception classes created by the maintainer