« Back to channel list

#ruby - 13 November 2018

« Back 1 day Forward 1 day »
[00:01:57] orbyt_: has joined #ruby
[00:03:31] akosednar: has joined #ruby
[00:06:06] arescorpio: has joined #ruby
[00:17:13] patr0clus: has joined #ruby
[00:20:44] akosednar: has joined #ruby
[00:22:50] ansraliant: has joined #ruby
[00:34:01] Exuma: has joined #ruby
[00:35:55] sanscoeur: has joined #ruby
[00:41:56] EXCHGR: has joined #ruby
[01:02:31] RougeR: has joined #ruby
[01:16:42] weaksauce: has joined #ruby
[01:49:41] CrazyEddy: has joined #ruby
[02:15:11] _whitelogger: has joined #ruby
[02:20:12] Dimik: has joined #ruby
[02:22:29] bmurt: has joined #ruby
[02:32:19] tdy: has joined #ruby
[02:44:20] nchambers: has joined #ruby
[02:45:07] esrse: has joined #ruby
[02:46:18] sshock: has joined #ruby
[02:49:20] cd: has joined #ruby
[02:53:38] cd: has joined #ruby
[02:56:30] sshock: has left #ruby: ()
[02:58:23] Nahra: has joined #ruby
[03:01:34] darkhanb: has joined #ruby
[03:19:26] tonyhb: has joined #ruby
[03:26:10] venmx: has joined #ruby
[03:34:11] Xiti: has joined #ruby
[03:37:54] za1b1tsu: has joined #ruby
[03:50:16] white_lilies: has joined #ruby
[03:55:51] nchambers: has joined #ruby
[04:09:11] _whitelogger: has joined #ruby
[04:09:15] braincrash: has joined #ruby
[04:14:27] roshanavand1: has joined #ruby
[04:15:58] nowhereman: has joined #ruby
[04:26:26] MoritaShinobu: has joined #ruby
[04:53:38] kapil____: has joined #ruby
[04:56:58] dellavg_: has joined #ruby
[04:57:05] Exuma: has joined #ruby
[04:59:31] Guest53511: has joined #ruby
[05:09:46] Exuma: has joined #ruby
[05:13:36] za1b1tsu: has joined #ruby
[05:20:51] eckhardt_: has joined #ruby
[05:49:52] hays: how should i implement equality tests for a class
[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:56:14] havenwood: hays: It's either equal or not? There's not greater than, less than, etc?
[05:57:31] havenwood: hays: Defining #== makes sense if you want to check `==` and `!=`.
[05:57:37] hays: well, lets just say its equality
[05:57:53] havenwood: hays: If you want more comparisons, `include Comparable` and define #<=>.
[05:58:19] hays: am i correct that i'lll need to be able to make this determination through public accessors
[05:58:48] havenwood: hays: Usually you define a public #== method.
[05:58:48] hays: since def ==(other) i need access to what's in other
[05:59:22] havenwood: hays: You might consider also defining #eql? and #=== for your custom class, if those make sense.
[06:00:20] aupadhye: has joined #ruby
[06:00:24] hays: im kinda stuck on this basic question
[06:00:51] hays: seems ilke i need to know whats in other
[06:01:02] havenwood: hays: it's the method argument
[06:01:53] havenwood: &>> class NeverEqual; def == _; false end end; NeverEqual.new == 42
[06:01:57] rubydoc: # => false (https://carc.in/#/r/5i79)
[06:03:07] hays: very simple example https://dpaste.de/yEhX
[06:03:47] hays: i think im missing something very basic here
[06:04:03] havenwood: hays: ah, I see what you're asking
[06:04:27] havenwood: hays: you can use meta-programming to get at private methods, when that makes sense
[06:04:59] havenwood: hays: other.send(:a)
[06:05:05] hays: but also there are things like 1==1.0
[06:05:13] havenwood: other.instance_method_get(:@a)
[06:05:42] hays: ok, ill read about send and instance_method_get
[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:07:28] havenwood: hays: or respond to #to_int
[06:08:18] jtdowney: has joined #ruby
[06:08:50] hays: yeah, that's an interesting solution
[06:09:15] hays: a == other.to_i or to_s or whatever might make sense
[06:09:43] hays: then I also should read about eql? vs ==
[06:09:51] hays: and then verify whether === is the same as is_a
[06:09:53] havenwood: hays: #to_int is a special conversion just for this case, slightly different from #to_i
[06:10:24] hays: is there to_str, to_flt, etc? not sure I understand that
[06:10:28] havenwood: hays: === is for case statements, and predicate enumerable methods, and other such implicit use
[06:10:48] havenwood: those are for these implicit conversions, rather than explicit use
[06:11:09] havenwood: (by convention and stdlib pattern)
[06:11:23] havenwood: core/stdlib
[06:11:25] hays: 1.to_flt seems undefined
[06:11:53] havenwood: hays: yeah, there's no #to_flt
[06:12:33] hays: yea, ok i see to_int and to_str
[06:13:05] havenwood: hays: to_int, to_str, to_ary, to_hash
[06:13:45] aupadhye: has joined #ruby
[06:13:53] havenwood: hays: https://zverok.github.io/blog/2016-01-18-implicit-vs-expicit.html
[06:14:04] hays: ahh i see and to_i is allowed to be approximate, or truncate
[06:14:08] hays: whereas to_int would not
[06:14:21] hays: hmm. maybe not
[06:14:33] hays: 1.30.to_int works
[06:20:56] conta: has joined #ruby
[06:20:59] hays: ok. this seems a bit mushy in my head but I think I get the general idea
[06:21:38] hays: I kinda think Float.to_int shouldn't be implemented
[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:23:10] hays: but clearly shouldn't be a Dog.to_int
[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:24:32] hays: So it does not require like a one-to-one mapping, but just semantic similarity
[06:25:23] reber: has joined #ruby
[06:25:26] aupadhye: has joined #ruby
[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:33:08] hays: not sure how JSON.generate would treat it on the way out through
[06:33:52] roshanavand: has joined #ruby
[06:35:11] hays: ick. it returns the #<A:0x09340392>\ stuff
[06:45:35] hays: ok, so my classes just need to implement to_json (*other)
[06:46:59] sauvin: has joined #ruby
[06:47:35] armyriad: has joined #ruby
[06:49:10] armyriad: has joined #ruby
[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 *
[07:08:43] hays: here's the ways I see it https://dpaste.de/BFiz
[07:09:35] za1b1tsu: has joined #ruby
[07:09:59] mangold: has joined #ruby
[07:13:55] venmx: has joined #ruby
[07:23:34] dionysus69: has joined #ruby
[07:34:30] phaul: has joined #ruby
[07:55:24] mangold: has joined #ruby
[07:56:34] mangold: has joined #ruby
[08:05:45] clemens3: has joined #ruby
[08:08:31] clemens3: has joined #ruby
[08:13:55] yohji: has joined #ruby
[08:26:41] whysthatso: has joined #ruby
[08:27:29] akosednar: has joined #ruby
[08:30:47] gix: has joined #ruby
[08:31:26] elphe: has joined #ruby
[08:37:09] queip: has joined #ruby
[08:40:53] akosednar: has joined #ruby
[08:50:09] burgestrand: has joined #ruby
[08:53:17] aufi: has joined #ruby
[08:54:56] aufi_: has joined #ruby
[08:55:18] Nicmavr: has joined #ruby
[08:57:58] elphe: has joined #ruby
[08:58:41] aufi: has joined #ruby
[08:59:35] akemot: has joined #ruby
[08:59:48] akosednar: has joined #ruby
[09:06:32] akemot: has joined #ruby
[09:07:46] elphe: has joined #ruby
[09:09:12] akem: has joined #ruby
[09:13:01] AltLock: has joined #ruby
[09:14:46] AltLock: has joined #ruby
[09:15:51] aufi_: has joined #ruby
[09:23:32] elphe: has joined #ruby
[09:24:51] roshanavand: has joined #ruby
[09:25:06] Guest53511: has joined #ruby
[09:32:51] maufart__: has joined #ruby
[09:45:42] Burgestr_: has joined #ruby
[09:46:08] aupadhye: has joined #ruby
[09:47:37] venmx: has joined #ruby
[09:47:59] aupadhye: has joined #ruby
[09:58:11] aupadhye: has joined #ruby
[10:17:21] voolik: has joined #ruby
[10:26:26] aupadhye: has joined #ruby
[10:33:07] apparition: has joined #ruby
[10:36:00] Paraxial: has joined #ruby
[10:36:49] lxsameer: has joined #ruby
[10:51:08] akem: has joined #ruby
[10:58:37] conta: has joined #ruby
[11:17:09] aupadhye: has joined #ruby
[11:22:41] aupadhye: has joined #ruby
[11:28:39] despai: has joined #ruby
[11:30:50] despai: has joined #ruby
[11:38:04] AJA4350: has joined #ruby
[11:53:39] Cthulu201: has joined #ruby
[12:16:13] meinside: has joined #ruby
[12:16:26] im0nde: has joined #ruby
[12:21:23] Dbugger: has joined #ruby
[12:29:36] m27frogy: has joined #ruby
[12:33:20] LinuxKnight: has joined #ruby
[12:39:37] voolik: has joined #ruby
[12:44:22] vondruch: has joined #ruby
[12:54:09] akem: has joined #ruby
[12:55:41] roshanavand: has joined #ruby
[12:56:42] akem: has joined #ruby
[13:00:39] akem: has joined #ruby
[13:08:27] nertzy: has joined #ruby
[13:17:50] joast: has joined #ruby
[13:18:59] voolik: has joined #ruby
[13:19:17] aufi: has joined #ruby
[13:44:00] vondruch: has joined #ruby
[13:46:01] gnufied: has joined #ruby
[13:58:32] yohji: has joined #ruby
[14:07:30] dtzuzu: has joined #ruby
[14:08:26] SuperLag: has joined #ruby
[14:13:59] JamieD: has joined #ruby
[14:16:01] leafyleong: has joined #ruby
[14:22:11] akem: has joined #ruby
[14:31:38] dtzuzu: has joined #ruby
[14:40:21] Inline: has joined #ruby
[14:48:16] bmurt: has joined #ruby
[14:53:57] jsc: has joined #ruby
[14:56:04] rippa: has joined #ruby
[15:02:40] leafyleong: has joined #ruby
[15:07:13] Xiti: has joined #ruby
[15:11:29] status402: has joined #ruby
[15:15:41] dmitch: has joined #ruby
[15:24:27] conta: has joined #ruby
[15:26:33] nchambers: has joined #ruby
[15:28:52] m27frogy: has joined #ruby
[15:28:58] Xiti`: has joined #ruby
[15:30:11] akem: has joined #ruby
[15:37:39] despai: has joined #ruby
[15:39:10] status402: has joined #ruby
[15:40:52] voolik: has joined #ruby
[15:42:33] MoritaShinobu: has joined #ruby
[15:43:54] Xiti: has joined #ruby
[15:45:11] jetchisel: has joined #ruby
[15:45:16] AltLock: has joined #ruby
[15:52:41] nicesignal: has joined #ruby
[16:13:48] roshanavand: has joined #ruby
[16:17:48] queip: has joined #ruby
[16:18:26] lxsameer: has joined #ruby
[16:25:32] queip: has joined #ruby
[16:28:35] MoritaShinobu: has joined #ruby
[16:29:33] MoritaShinobu: has joined #ruby
[16:30:58] MoritaShinobu: has joined #ruby
[16:31:35] AltLock: has joined #ruby
[16:34:28] Rapture: has joined #ruby
[16:37:56] despai: has joined #ruby
[16:50:27] Puffball: has joined #ruby
[16:50:45] JamieD: has joined #ruby
[16:51:16] conta: has joined #ruby
[16:53:16] roshanavand: has joined #ruby
[16:56:23] maryo: has joined #ruby
[17:04:38] Exuma: has joined #ruby
[17:06:02] jcarl43: has joined #ruby
[17:09:33] dmitch: has joined #ruby
[17:11:06] akem: has joined #ruby
[17:13:30] cthu|: has joined #ruby
[17:19:13] bmurt: has joined #ruby
[17:21:35] darkhanb: has joined #ruby
[17:23:15] orbyt_: has joined #ruby
[17:31:17] clemens3: has joined #ruby
[17:34:14] jesfre: has joined #ruby
[17:37:36] lxsameer: has joined #ruby
[17:43:41] clemens3_: has joined #ruby
[17:45:59] lxsameer: has joined #ruby
[17:46:39] queip: has joined #ruby
[17:48:10] c0ncealed4: has joined #ruby
[17:52:37] sanscoeur: has joined #ruby
[17:56:14] dmitch: has joined #ruby
[18:01:58] ur5us: has joined #ruby
[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:05:18] cd: has joined #ruby
[18:06:06] JamieD: has joined #ruby
[18:06:22] AltLock: has joined #ruby
[18:07:37] lxsameer: has joined #ruby
[18:16:45] akem: has joined #ruby
[18:20:32] jesfre: has joined #ruby
[18:20:59] roshanavand: has joined #ruby
[18:21:31] tag: has joined #ruby
[18:27:23] roshanavand: has joined #ruby
[18:33:23] ivanskie: has joined #ruby
[18:36:50] discopatrick: has joined #ruby
[18:43:25] jesfre: has joined #ruby
[18:48:11] al2o3-cr: has joined #ruby
[18:51:13] queip: has joined #ruby
[18:52:22] emerson: has joined #ruby
[18:58:31] akaiiro: has joined #ruby
[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:05:05] roshanavand: has joined #ruby
[19:08:13] lxsameer: has joined #ruby
[19:16:57] OrangeManBad: has joined #ruby
[19:18:33] roshanavand: has joined #ruby
[19:20:28] phaul: has joined #ruby
[19:28:08] akaiiro: has joined #ruby
[19:31:29] eckhardt_: has joined #ruby
[19:34:58] Nicmavr: has joined #ruby
[19:43:03] Mike11: has joined #ruby
[19:43:44] BTRE: has joined #ruby
[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?
[19:47:06] alicef: has joined #ruby
[19:54:22] Xiti: has joined #ruby
[19:56:36] ellcs: has joined #ruby
[20:01:33] Inside: has joined #ruby
[20:01:51] Inside: Why is IRC so quiet? OH I AM NOT CONNECTED.
[20:04:25] al2o3-cr: that'll do it ;)
[20:07:19] im0nde: has joined #ruby
[20:11:41] despai: has joined #ruby
[20:12:40] DigitallyBorn: has joined #ruby
[20:13:53] ben: has joined #ruby
[20:14:56] cp_dev: has joined #ruby
[20:15:23] ben: Are gems always libraries or do applications also get packaged as gems?
[20:15:43] nchambers: i've packaged applications as gems before
[20:15:58] nchambers: ruby-gems actually has a guide for specifically that
[20:16:06] ben: ah, cool, thank you
[20:16:34] ben: I'm a bit lost with gemfiles and gemspecs and some half-packaged scripts floating around my machine :)
[20:18:33] roshanavand: has joined #ruby
[20:27:05] Dbugger: has joined #ruby
[20:27:47] kapil____: has joined #ruby
[20:30:49] GodFather_: has joined #ruby
[20:32:31] akaiiro: has joined #ruby
[20:35:27] Furai: has joined #ruby
[20:37:20] orbyt_: has joined #ruby
[20:46:59] queip: has joined #ruby
[20:48:23] icarus: has joined #ruby
[20:48:30] despai: has joined #ruby
[20:58:32] akaiiro: has joined #ruby
[20:59:03] RougeR: has joined #ruby
[21:07:55] whysthatso: has joined #ruby
[21:16:08] ivanskie: has joined #ruby
[21:16:11] snickers: has joined #ruby
[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:23:51] wickedbloodfart: has joined #ruby
[21:26:45] ivanskie: bundle clean --force made it worse. :(
[21:35:32] DarthGandalf: has joined #ruby
[21:37:37] eckhardt_: has joined #ruby
[21:38:44] ivanskie: somehow i've just fixed it
[21:38:46] ivanskie: don't know how
[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:40:45] ivanskie: https://github.com/awesome-print/awesome_print
[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.
[21:41:32] ivanskie: so im now removing awesome_print dependency entirely since its not critical
[21:41:54] bmurt: has joined #ruby
[21:43:45] AJA4350: has joined #ruby
[21:45:26] ivanskie: which only means that i was doing something wrong
[21:51:31] queip: has joined #ruby
[21:59:57] ua: has joined #ruby
[22:09:53] jyaworski: has joined #ruby
[22:10:23] gigetoo: has joined #ruby
[22:10:52] madhatter: has joined #ruby
[22:12:30] Lytol: has joined #ruby
[22:15:43] DigitallyBorn: has joined #ruby
[22:20:08] cranq: has joined #ruby
[22:20:51] gigetoo: has joined #ruby
[22:21:14] TvL2386: has joined #ruby
[22:22:14] icarus: has joined #ruby
[22:23:51] armyriad: has joined #ruby
[22:27:46] Emmanuel_Chanel: has joined #ruby
[22:35:33] blackmesa: has joined #ruby
[22:37:40] donofrio_: has joined #ruby
[22:37:45] armyriad: has joined #ruby
[22:38:45] donofrio_: has joined #ruby
[22:40:28] go|dfish: has joined #ruby
[22:44:58] Rapture: has joined #ruby
[22:49:40] queip: has joined #ruby
[22:51:16] bmurt: has joined #ruby
[22:55:25] yokel: has joined #ruby
[23:13:17] venmx: has joined #ruby
[23:14:23] vondruch: has joined #ruby
[23:19:21] voiceftp: has joined #ruby
[23:19:42] Guest24308: has joined #ruby
[23:19:44] vondruch: has joined #ruby
[23:20:46] vondruch: has joined #ruby
[23:28:15] venmx: has joined #ruby
[23:32:25] relyks: has joined #ruby
[23:32:50] relyks: is there way to determine what exceptions can be produced from a method?
[23:33:49] venmx_: has joined #ruby
[23:42:34] blackmesa1: has joined #ruby
[23:43:57] Radar: relyks: what's the method?
[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:45:34] Radar: begin; TheirCode.a_method; rescue => e; <do something with e, the exception>; end
[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:32] relyks: I guess that's a problem with dealing with dynamically typed code lol
[23:48:40] relyks: still love ruby <3
[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:06] Radar: It is not possible to predict.
[23:49:37] relyks: yeah, true, but perhaps a method throws specific exception classes created by the maintainer
[23:49:50] relyks: but I agree
[23:51:01] jetchisel: has joined #ruby
[23:53:55] bmurt: has joined #ruby
[23:54:45] queip: has joined #ruby
[23:55:35] troulouliou_div2: has joined #ruby
[23:59:21] sanscoeur: has joined #ruby