« Back to channel list

#ruby - 20 December 2017

« Back 1 day Forward 1 day »
[00:03:24] pharma_joe: has joined #ruby
[00:03:59] tjbp: has joined #ruby
[00:05:10] tjbp: has joined #ruby
[00:09:02] ramfjord: has joined #ruby
[00:10:32] joast: has joined #ruby
[00:10:49] cschneid_: has joined #ruby
[00:10:56] alfiemax: has joined #ruby
[00:11:54] my123: has joined #ruby
[00:11:55] my123: has joined #ruby
[00:14:51] ramfjord: has joined #ruby
[00:15:08] havenwood: >> class KeywordStruct; def initialize struct_name, **keywords; @struct = Object.const_set(struct_name, Struct.new(*keywords.keys)).new(*keywords.values); end; def method_missing(meth, *args); @struct.public_send(meth, *args); end; def respond_to_missing?(meth, include_private = false); @struct.respond_to? meth; end end; radar = KeywordStruct.new(:Radar, aim: true, name: 'Radar'); radar.aim
[00:15:09] ruby[bot]: havenwood: # => true (https://eval.in/922425)
[00:16:47] havenwood: dry-rb has an immutable struct and if I recall it takes keyword arguements
[00:18:03] k0mpa: has joined #ruby
[00:21:36] ramfjord: has joined #ruby
[00:22:54] havenwood: http://dry-rb.org/gems/dry-struct/
[00:26:14] milardovich: has joined #ruby
[00:26:23] pharma_joe: has joined #ruby
[00:27:30] ramfjord: has joined #ruby
[00:30:21] tAn: has joined #ruby
[00:32:07] ur5us: has joined #ruby
[00:32:35] ur5us: has joined #ruby
[00:35:18] MrBismuth: has joined #ruby
[00:36:18] moei: has joined #ruby
[00:37:31] macccccccccc: has joined #ruby
[00:38:57] ruschlem2: has left #ruby: ()
[00:40:58] pastorinni: has joined #ruby
[00:41:06] sparr: has joined #ruby
[00:43:04] veeti: has joined #ruby
[00:45:04] ramfjord: has joined #ruby
[00:56:08] ramfjord: has joined #ruby
[00:57:05] Jameser: has joined #ruby
[00:59:13] Mvfc: has joined #ruby
[01:02:15] alex``: has joined #ruby
[01:06:14] Mvfc: has joined #ruby
[01:07:37] hahuang65: has joined #ruby
[01:09:21] cdg: has joined #ruby
[01:09:42] tAn: has joined #ruby
[01:12:02] Mvfc: has joined #ruby
[01:12:45] ur5us: has joined #ruby
[01:13:06] ramfjord: has joined #ruby
[01:14:41] pilne: has joined #ruby
[01:16:30] Mvfc: has joined #ruby
[01:16:53] macccccccccc: has joined #ruby
[01:19:08] cagomez: has joined #ruby
[01:19:17] pb122: has joined #ruby
[01:19:59] oz: has joined #ruby
[01:21:56] veeti: has joined #ruby
[01:22:36] guardianx: has joined #ruby
[01:30:06] Mvfc: has joined #ruby
[01:34:39] eckhardt: has joined #ruby
[01:36:28] Azure: has joined #ruby
[01:42:05] pastorinni: has joined #ruby
[01:43:50] vondruch: has joined #ruby
[01:46:09] mitchellvanw: has joined #ruby
[01:47:21] RealMarc: has joined #ruby
[01:47:58] zapata: has joined #ruby
[01:48:20] orbyt_: has joined #ruby
[01:55:23] tAn: has joined #ruby
[01:57:00] RougeT430: has joined #ruby
[01:59:08] webguynow: has joined #ruby
[02:01:56] enterprisey: has joined #ruby
[02:02:39] zwliew: has joined #ruby
[02:03:28] QualityAddict: has joined #ruby
[02:10:42] alfiemax: has joined #ruby
[02:24:28] d^sh: has joined #ruby
[02:31:14] jnollette: has joined #ruby
[02:32:14] tAn: has joined #ruby
[02:44:44] rrutkowski: has joined #ruby
[02:44:50] jenrzzz: has joined #ruby
[02:44:58] jenrzzz: has joined #ruby
[02:47:02] bmurt: has joined #ruby
[02:47:46] therealGent: has joined #ruby
[02:48:27] rrutkowski: has joined #ruby
[02:50:47] iMadper: has joined #ruby
[02:51:34] mtkd: has joined #ruby
[02:53:25] Radar: havenwood: right. I was trying to do it without using an extra gem. But given this project is already using some of the dry-* class of gems, dry-struct probably makes the most sense.
[02:58:13] pastorinni: has joined #ruby
[03:00:18] cadillac_: has joined #ruby
[03:05:48] orbyt_: has joined #ruby
[03:06:13] alfiemax: has joined #ruby
[03:08:54] hahuang65: has joined #ruby
[03:09:05] veeti: has joined #ruby
[03:10:07] tAn: has joined #ruby
[03:11:42] bmurt: has joined #ruby
[03:18:20] alfiemax: has joined #ruby
[03:32:19] MrBusiness: has joined #ruby
[03:36:13] astronavt: has joined #ruby
[03:38:24] DmitryBochkarev: has joined #ruby
[03:39:46] tcopeland1: has joined #ruby
[03:42:33] skweek: has joined #ruby
[03:49:48] tAn: has joined #ruby
[03:53:25] alfiemax: has joined #ruby
[03:54:15] tcopeland1: has joined #ruby
[03:56:18] cschneid_: has joined #ruby
[04:05:48] SCHAPiE: has joined #ruby
[04:06:08] cschneid_: has joined #ruby
[04:07:25] pastorinni: has joined #ruby
[04:10:19] veeti: has joined #ruby
[04:18:15] gix-: has joined #ruby
[04:24:23] naprimer: has joined #ruby
[04:26:53] jenrzzz: has joined #ruby
[04:27:21] nso95: has joined #ruby
[04:27:47] tAn: has joined #ruby
[04:29:37] monodoh: has joined #ruby
[04:29:45] monodoh: has left #ruby: ()
[04:31:40] al2o3-cr: has joined #ruby
[04:37:53] plexigras: has joined #ruby
[04:38:10] rrutkowski: has joined #ruby
[04:44:22] rhebz916: has joined #ruby
[04:44:40] d^sh: has joined #ruby
[04:45:37] A124: has joined #ruby
[04:55:55] nadir: has joined #ruby
[05:00:33] A124: has joined #ruby
[05:01:08] mtkd: has joined #ruby
[05:03:05] Emmanuel_Chanel: has joined #ruby
[05:06:31] tAn: has joined #ruby
[05:09:43] hahuang65: has joined #ruby
[05:14:44] chmurifree: has joined #ruby
[05:18:05] coderphive: has joined #ruby
[05:19:47] anisha: has joined #ruby
[05:20:20] garyserj: has joined #ruby
[05:27:28] rhebz916: has joined #ruby
[05:36:32] armyriad: has joined #ruby
[05:37:39] rrutkowski: has left #ruby: ()
[05:38:29] aupadhye: has joined #ruby
[05:39:56] iamarun: has joined #ruby
[05:41:11] dionysus69: has joined #ruby
[05:42:20] tAn: has joined #ruby
[05:43:40] duderono_: has joined #ruby
[05:55:22] rhebz916: has joined #ruby
[06:00:15] alfiemax: has joined #ruby
[06:01:14] skweek: has joined #ruby
[06:01:56] skweek: has joined #ruby
[06:02:27] pb122-two: has joined #ruby
[06:03:16] skweek: has joined #ruby
[06:06:49] skweek: has joined #ruby
[06:09:45] cdg: has joined #ruby
[06:11:30] rippa: has joined #ruby
[06:20:46] s2013: has joined #ruby
[06:22:28] alfiemax: has joined #ruby
[06:28:34] reber: has joined #ruby
[06:33:13] veeti: has joined #ruby
[06:45:23] john__: has joined #ruby
[06:54:51] growp: has joined #ruby
[06:55:41] conta: has joined #ruby
[06:56:12] tAn: has joined #ruby
[06:59:40] CrazyEddy: has joined #ruby
[07:10:35] hahuang65: has joined #ruby
[07:10:49] tAn: has joined #ruby
[07:16:46] ur5us: has joined #ruby
[07:21:54] haxx0r: has joined #ruby
[07:22:31] haxx0r: =(2^64-1-supply*10^12)*2^-20*10^-12
[07:22:36] haxx0r: in excel works great.
[07:22:39] haxx0r: cant get it into ruby
[07:22:41] haxx0r: supply = 0
[07:23:24] haxx0r: *2^-20*10^-12 must be * (2**-20) * (10**-12). right?
[07:23:56] growp: has joined #ruby
[07:24:02] haxx0r: (2^64-1-supply*10^12) should be 2**64 -1 -supply * (10**12) ?
[07:24:18] haxx0r: br = (2**64-1- supply * (10**12))*(2**-20)*(10**-12)
[07:24:18] haxx0r: => (3689348814741910323/209715200000000000)
[07:24:30] haxx0r: the correct result should be 17.5921860444
[07:25:47] haxx0r: br = (2**64-1- supply * (10**12))*(2**-20)*(10**-12).to_f
[07:25:47] haxx0r: => 17.592186044416
[07:25:50] haxx0r: looks correct :D
[07:26:04] darkness: has joined #ruby
[07:27:08] bkxd: has joined #ruby
[07:31:27] CrazyEddy: has joined #ruby
[07:35:05] despai: has joined #ruby
[07:35:41] cdg: has joined #ruby
[07:40:46] bkxd: has joined #ruby
[07:41:49] chrizzychriz: has joined #ruby
[07:42:21] chrizzychriz: has left #ruby: ()
[07:44:43] elisaado: has joined #ruby
[07:47:32] apeiros: has joined #ruby
[07:47:45] CrazyEddy: has joined #ruby
[07:49:59] andikr: has joined #ruby
[07:50:24] amatas: has joined #ruby
[07:51:04] anas: has joined #ruby
[07:55:30] jenrzzz: has joined #ruby
[07:56:53] CrazyEddy: has joined #ruby
[07:58:31] CrazyEddy: has joined #ruby
[07:58:58] milardovich: has joined #ruby
[07:59:10] rrutkowski: has joined #ruby
[08:00:52] alex``: has joined #ruby
[08:01:50] stoffus: has joined #ruby
[08:02:11] rrutkowski: has joined #ruby
[08:02:58] burgestrand: has joined #ruby
[08:04:58] bkxd: has joined #ruby
[08:05:28] mtkd: has joined #ruby
[08:06:14] rrutkowski: has joined #ruby
[08:06:14] jaruga: has joined #ruby
[08:07:02] biberu: has joined #ruby
[08:07:29] rhebz916: has joined #ruby
[08:11:42] cdg: has joined #ruby
[08:11:55] TomyWork: has joined #ruby
[08:15:38] hs366: has joined #ruby
[08:17:53] d^sh: has joined #ruby
[08:22:43] cschneid_: has joined #ruby
[08:22:59] CrazyEddy: has joined #ruby
[08:25:05] claudiuinberlin: has joined #ruby
[08:25:37] mark_66: has joined #ruby
[08:26:33] pikislabis: has joined #ruby
[08:31:17] rabajaj: has joined #ruby
[08:39:07] bkxd_: has joined #ruby
[08:42:22] ferr: has joined #ruby
[08:43:16] InfinityFye: has joined #ruby
[08:47:57] tAn: has joined #ruby
[08:50:52] InfinityFye: has left #ruby: ("Leaving")
[08:51:47] moei: has joined #ruby
[08:54:44] pdcawley: has joined #ruby
[08:55:21] CrazyEddy: has joined #ruby
[08:56:00] Riddell: has joined #ruby
[08:58:01] bkxd: has joined #ruby
[09:00:03] TvL: has joined #ruby
[09:02:40] VladGh_: has joined #ruby
[09:05:26] Dimik: has joined #ruby
[09:05:30] CrazyEddy: has joined #ruby
[09:05:53] jenrzzz: has joined #ruby
[09:05:53] jenrzzz: has joined #ruby
[09:10:01] jaruga: has joined #ruby
[09:11:39] hahuang65: has joined #ruby
[09:17:25] KeyJoo: has joined #ruby
[09:18:58] cschneid_: has joined #ruby
[09:20:45] ur5us: has joined #ruby
[09:27:16] marr: has joined #ruby
[09:36:13] coderxin: has joined #ruby
[09:44:41] Serpent7776: has joined #ruby
[09:50:58] p0p0pr37: has joined #ruby
[09:51:00] kapil___: has joined #ruby
[09:51:16] Cork: where is File.write documented?
[09:51:24] Cork: can't find it in https://ruby-doc.org/core-2.0.0/File.html
[09:51:28] bronson_: has joined #ruby
[09:51:56] ar: Cork: https://ruby-doc.org/core-2.4.0/IO.html#method-c-write
[09:52:08] Cork: ah in io
[09:52:24] ar: (or this https://ruby-doc.org/core-2.4.0/IO.html#method-i-write)
[09:52:41] Cork: ya, it was the former
[09:52:46] Beams: has joined #ruby
[09:53:53] alfiemax: has joined #ruby
[09:56:08] cadillac_: has joined #ruby
[09:58:57] ferr: has left #ruby: ("WeeChat 2.0")
[10:01:48] cabotto: has joined #ruby
[10:05:14] bkxd: has joined #ruby
[10:07:57] ams__: has joined #ruby
[10:09:32] Cavallari: has joined #ruby
[10:14:38] nevermoregnr: has joined #ruby
[10:15:43] Junaos: has joined #ruby
[10:16:13] eam: has joined #ruby
[10:22:41] alfiemax_: has joined #ruby
[10:26:35] alfiemax: has joined #ruby
[10:33:09] leitz: has joined #ruby
[10:34:44] leitz: What are the options for a Ruby CLI program to display, edit, and save multi-line text? For example, to pull a set of lines from a config file, let you edit them, and then end the edit session.
[10:35:57] Beams_: has joined #ruby
[10:41:15] jsrtr: has joined #ruby
[10:43:29] Jameser: has joined #ruby
[10:43:29] bkxd: has joined #ruby
[10:51:59] amatas: has joined #ruby
[10:52:31] workmad3: has joined #ruby
[10:53:00] ldnunes: has joined #ruby
[10:53:15] alfiemax: has joined #ruby
[10:54:31] cabotto: has joined #ruby
[10:55:12] al2o3-cr: has joined #ruby
[11:03:07] bkxd: has joined #ruby
[11:05:51] bkxd_: has joined #ruby
[11:05:54] ur5us: has joined #ruby
[11:10:07] cdg: has joined #ruby
[11:10:41] minimalism: has joined #ruby
[11:12:29] hahuang65: has joined #ruby
[11:16:02] cabotto: has joined #ruby
[11:26:22] bkxd: has joined #ruby
[11:28:37] bkxd: has joined #ruby
[11:35:37] al2o3-cr: has joined #ruby
[11:48:40] JaccoP: has joined #ruby
[11:51:47] bkxd: has joined #ruby
[11:53:43] shinnya: has joined #ruby
[11:53:49] scmlinux: has joined #ruby
[11:54:55] bkxd: has joined #ruby
[11:56:25] Psybur: has joined #ruby
[11:59:53] dionysus69: has joined #ruby
[12:00:59] conta: has joined #ruby
[12:02:35] milardovich: has joined #ruby
[12:03:30] Alex: has joined #ruby
[12:04:08] cabotto: has joined #ruby
[12:04:11] tvw: has joined #ruby
[12:04:36] anas: has joined #ruby
[12:05:14] alfiemax: has joined #ruby
[12:06:36] Guest19292: has joined #ruby
[12:10:59] scmlinux: has joined #ruby
[12:17:09] conta: has joined #ruby
[12:17:26] pikislabis: has joined #ruby
[12:20:14] rhebz916: has joined #ruby
[12:20:27] Musashi007: has joined #ruby
[12:23:51] DaniG2k: has joined #ruby
[12:24:06] evidex: has joined #ruby
[12:24:21] mistergibson: has joined #ruby
[12:26:25] Beams: has joined #ruby
[12:27:34] coderxin: has joined #ruby
[12:30:27] morfin60: has joined #ruby
[12:30:36] morfin60: what happens if you include something twice?
[12:31:01] morfin60: ancestors list will have only one item anyway right?
[12:31:12] ar: morfin60: you mean, `require`?
[12:31:18] morfin60: include in class
[12:32:09] apeiros: morfin60: depends. if it's in the same class - nothing afaik
[12:32:35] apeiros: iirc it's slightly different if you include it twice in an ancestry chain. got to try how exactly, though
[12:33:15] apeiros: oh, the self.included callback is triggered every time you include it. so not really nothing.
[12:34:28] morfin60: i want to use paperclip gem in both rails app and application using ActiveRecord without rails
[12:34:36] morfin60: models are in shared gem
[12:36:05] miskatonic: has joined #ruby
[12:36:56] morfin60: in Rails application there is Railtie which basically include Paperclip::Glue into ActiveRecord::base class
[12:37:02] morfin60: https://github.com/thoughtbot/paperclip/blob/master/lib/paperclip/railtie.rb
[12:37:59] morfin60: but outside of Rails application i should do this myself to let model use has_attached_file function etc
[12:38:00] apeiros: should I lol @ line 21?
[12:39:01] morfin60: it just reopen class and define class method no?
[12:39:29] apeiros: yes. it reopens the class it just closed 2 lines above.
[12:39:39] morfin60: i know idk why they did it
[12:41:05] morfin60: anyway that's how this is "injected" when inside of Rails app, some guy suggested include Paperclip::Glue in model that's why i asked
[12:41:09] apeiros: couple of possible approaches: 1) use different requires for in/outside rails (e.g. require 'yourgem/activerecord' vs. 'yourgem/rails') where in the "outside rails" variant, you do the Paperclip::Railtie.insert
[12:41:13] morfin60: because i am not sure it's right way
[12:41:36] apeiros: 2) just call Paperclip::Railtie.insert regardless and claim it's paperclip's responsibility to handle potential multiple calls
[12:42:20] apeiros: 3) implement an assertion yourself (`unless ActiveRecord::Base < Paperclip::Glue`) and only call Paperclip::Railtie.insert if it passes
[12:42:32] apeiros: there are certainly even more ways.
[12:43:30] apeiros: oh, actually, not Railtie.insert, since that requires Rails (Rails.logger) - replace with "setting the logger yourself + including it in AR::Base"
[12:44:05] Musashi007: has joined #ruby
[12:46:39] CrazyEddy: has joined #ruby
[12:53:30] jenrzzz: has joined #ruby
[12:53:30] jenrzzz: has joined #ruby
[12:53:47] tcopeland: has joined #ruby
[12:58:18] Psybur: has joined #ruby
[12:58:44] AJA4350: has joined #ruby
[13:01:32] alfiemax: has joined #ruby
[13:02:11] al2o3-cr: has joined #ruby
[13:02:44] Silthias: has joined #ruby
[13:02:46] Silthias: has left #ruby: ()
[13:05:31] chocoelho: has joined #ruby
[13:06:00] synthroid: has joined #ruby
[13:06:22] ur5us: has joined #ruby
[13:07:26] sina: has joined #ruby
[13:13:19] hahuang65: has joined #ruby
[13:20:18] cschneid_: has joined #ruby
[13:22:44] zautomata: has joined #ruby
[13:26:00] DaniG2k: has joined #ruby
[13:28:46] jnollette: has joined #ruby
[13:29:20] Jameser: has joined #ruby
[13:31:44] DmitryBochkarev: has joined #ruby
[13:32:01] jnollette: has joined #ruby
[13:34:09] bmurt: has joined #ruby
[13:42:56] aupadhye: has joined #ruby
[13:48:18] alfiemax: has joined #ruby
[13:49:05] mtkd: has joined #ruby
[13:52:43] Psybur: has joined #ruby
[13:52:46] vondruch: has joined #ruby
[13:53:53] cadillac_: has joined #ruby
[13:57:14] alfiemax: has joined #ruby
[14:05:57] Jameser: has joined #ruby
[14:06:06] pdcawley: has joined #ruby
[14:11:26] falaafel: has joined #ruby
[14:11:43] vichib: has joined #ruby
[14:12:31] sammi`: has joined #ruby
[14:15:21] aupadhye: has joined #ruby
[14:19:35] mikhael_k33hl: has joined #ruby
[14:21:13] mikhael_k33hl: If I have an instance -instance 1- with an instance variable @var, and I create an instance within that -instance 2- and pass that instance variable @var, will instance 1 and 2's @var point to the same object?
[14:21:16] mikhael_k33hl: variable, I mean
[14:22:09] apeiros: mikhael_k33hl: you can't point to variables
[14:22:12] alfiemax: has joined #ruby
[14:22:30] apeiros: the only way to reference variables is by name. and that's *usually* a bad idea.
[14:22:41] apeiros: (if done dynamically I mean)
[14:22:58] mikhael_k33hl: apeiros: Okay I might have said that wrong, what I mean was will the instance variable of instance 1 and 2 point ot the same object?
[14:23:42] Jameser: has joined #ruby
[14:23:51] cabotto: has joined #ruby
[14:24:07] apeiros: since your phrasing is not entirely clear, I'll rephrase: a = b # a will now *always* reference the same object as b (until the next assignment to either a or b)
[14:26:06] apeiros: you can check by using e.g. Object#equal? or Object#object_id
[14:27:21] mikhael_k33hl: Okay so if I have an instance variable A on instance 1, and within instance one I create instance 2 and passed the instance variable A to it, any changes I made on instance 2's instance variable A will reflect on instance 1 right?
[14:27:47] apeiros: any change made on the *object* will
[14:27:59] apeiros: the only thing you can change about a variable ever is which object it references
[14:28:13] apeiros: and that change is not reflected by other variables
[14:29:24] mikhael_k33hl: okay, so in instance 1 I have instance variable A which points to an Array Object. Within instance 1, I created instance 2 and passed variable A. Will the instance variable within instance 2 point to the same Array object as instance 1?
[14:30:06] mikhael_k33hl: Oh okay, got it.
[14:30:12] apeiros: though IMO at your level of understanding, paste example code to gist.github.com - just to make sure that what you think you say matches with what you actually say
[14:30:27] mikhael_k33hl: Just needed to confirm. I want to instantiate multiple child objects and share the same Array hehe
[14:30:51] apeiros: and as said, you can test for object identity with equal? and object_id
[14:31:17] mikhael_k33hl: apeiros: yup, will do, thanks mate
[14:37:32] enterprisey: has joined #ruby
[14:41:23] sammi`: has joined #ruby
[14:41:56] krawchyk: has joined #ruby
[14:48:31] sammi`: has joined #ruby
[14:55:31] iamarun: has joined #ruby
[14:59:03] alfiemax: has joined #ruby
[15:03:43] dinfuehr: has joined #ruby
[15:07:05] ur5us: has joined #ruby
[15:09:34] Jameser: has joined #ruby
[15:09:55] Jameser: has joined #ruby
[15:13:05] sammi`: has joined #ruby
[15:13:42] veeti: has joined #ruby
[15:13:46] polishdub: has joined #ruby
[15:14:26] hahuang65: has joined #ruby
[15:16:45] pastorinni: has joined #ruby
[15:17:22] DmitryBochkarev: has joined #ruby
[15:24:43] ltem: has joined #ruby
[15:28:13] selim: has joined #ruby
[15:28:15] A124: has joined #ruby
[15:29:03] safetypin: has joined #ruby
[15:32:12] oleo: has joined #ruby
[15:40:36] c0ncealed: has joined #ruby
[15:42:34] CrazyEddy: has joined #ruby
[15:45:12] s2013: has joined #ruby
[15:49:31] chocoelho: has joined #ruby
[15:50:21] sammi`: has joined #ruby
[15:51:44] growp: has joined #ruby
[15:56:11] garyserj: I can do puts blah[1][0]. But if I do puts blah[2][0] I get an error saying "in `<main>': undefined method `[]' for nil:NilClass (NoMethodError)" How can I test whether accessing blah[2][0] is nil / would cause that error?
[15:57:26] elomatreb: Either blah or blah[2] is nil in your case (accessing an array index that doesn't exist silently returns nil with [])
[15:57:37] nogic: has joined #ruby
[15:57:47] canton7: see whether blah[2] is nil or not. Check whether 2 is >= blah.length
[15:58:10] elomatreb: You may want to try Array#dig instead.
[15:58:26] troys: has joined #ruby
[16:01:04] garyserj: thanks. And if it's nil how do I it such that it's not nil so I can do blah[2][0]="asdf"?
[16:01:29] joast: has joined #ruby
[16:02:05] gregf_: has joined #ruby
[16:02:49] canton7: garyserj, if it's nil, do you want it to be a new array?
[16:02:54] garyserj: i guess it's adding an array of strings to the blah array.
[16:02:59] garyserj: that i want to do.
[16:03:19] garyserj: i should be able t ofind how to add an array of strings to an array
[16:09:29] cadillac_: has joined #ruby
[16:10:00] s2013: has joined #ruby
[16:11:13] cdolan: has joined #ruby
[16:12:38] cschneid_: has joined #ruby
[16:13:22] alfiemax: has joined #ruby
[16:19:21] cadillac_: has joined #ruby
[16:19:22] ldnunes: has joined #ruby
[16:20:01] dviola: has joined #ruby
[16:21:15] sammi`: has joined #ruby
[16:23:05] reber: has joined #ruby
[16:25:55] elisaado: has joined #ruby
[16:28:40] mostlybadfly: has joined #ruby
[16:29:01] VladGh: has joined #ruby
[16:30:40] cadillac_: has joined #ruby
[16:35:09] k0mpa: has joined #ruby
[16:35:21] reber__: has joined #ruby
[16:40:41] mikecmpb_: has joined #ruby
[16:41:14] KeyJoo: has joined #ruby
[16:41:31] cadillac_: has joined #ruby
[16:42:19] cagomez: has joined #ruby
[16:43:22] sammi`: has joined #ruby
[16:44:21] claudiuinberlin: has joined #ruby
[16:45:23] jnollette: has joined #ruby
[16:49:35] al2o3-cr: has joined #ruby
[16:52:09] TomyLobo: has joined #ruby
[16:54:11] mtkd: has joined #ruby
[16:56:25] sammi`: has joined #ruby
[16:57:39] kies: has joined #ruby
[17:03:41] c0dy: has joined #ruby
[17:07:33] alfiemax: has joined #ruby
[17:07:40] ur5us: has joined #ruby
[17:15:16] hahuang65: has joined #ruby
[17:22:06] aScottishBoat: has joined #ruby
[17:29:34] SeepingN: has joined #ruby
[17:30:39] fschuindt: has joined #ruby
[17:32:39] fschuindt: How can I use Ruby to capture HTTP requests made to my computer in the port 3000, for instance? Like: I want to send Rails a HTTP request and use Ruby outside Rails to get this request too. Is that possible?
[17:33:44] r0ph: has joined #ruby
[17:34:23] aScottishBoat: Have you looked at the docs?
[17:34:31] Ishido: has joined #ruby
[17:34:53] aScottishBoat: https://ruby-doc.org/stdlib-2.4.2/libdoc/net/http/rdoc/index.html
[17:36:31] claudiuinberlin: has joined #ruby
[17:36:49] SeepingN: 1 thing may listen on a part. 1
[17:37:28] Mvfc: has joined #ruby
[17:40:40] troulouliou_dev: has joined #ruby
[17:40:44] puppet645: has joined #ruby
[17:42:35] mrBen2k2k2k: has joined #ruby
[17:47:16] fschuindt: can I have two softwares listening the same port? I think that's my question
[17:47:35] nogic: has joined #ruby
[17:49:36] duderonomy: has joined #ruby
[17:49:48] SeepingN: I don't think so
[17:51:35] jeffreylevesque: has joined #ruby
[17:51:47] jeffreylevesque: i have an array: ['one', 'two', 'three']
[17:52:07] jeffreylevesque: i want to transform it to {one => {}, two => {}, three => {}}
[17:52:23] jeffreylevesque: i tried: @extensions.map { |v| {v => {}} }
[17:52:42] jeffreylevesque: that returned: {"one"=>{}}, {"two"=>{}}, {"three"=>{}}
[17:53:22] Papierkorb: jeffreylevesque: Have a look at Enumerable#each_with_object
[17:55:05] elomatreb: fschuindt: Classic approaches include some sort of packet capture software for doing that type of stuff, e.g. tcpdump on linux
[17:55:31] fschuindt: elomatreb: thank you, mate :)
[17:57:39] Papierkorb: fschuindt: In fact you can have multiple processes listening on the same port and address at once, but it's platform specific. On Linux, you have to set the socket option SO_REUSEPORT
[17:58:56] Papierkorb: fschuindt: This answer is really throughout on that topic: https://stackoverflow.com/a/14388707
[17:59:31] fschuindt: Papierkorb: nice! thank you
[17:59:36] aupadhye: has joined #ruby
[17:59:51] Dimik: has joined #ruby
[18:01:35] havenwood: jeffreylevesque: You want to map strings to local variables?
[18:02:16] dviola: has joined #ruby
[18:04:22] duderonomy: has joined #ruby
[18:04:27] havenwood: hoping you just meant strings and omitted parens
[18:05:53] Guest90: has joined #ruby
[18:06:29] havenwood: >> %w[one two three].map { |s| [s, {}] }.to_h # jeffreylevesque
[18:06:31] ruby[bot]: havenwood: # => {"one"=>{}, "two"=>{}, "three"=>{}} (https://eval.in/922864)
[18:06:31] despai: has joined #ruby
[18:06:40] havenwood: jeffreylevesque: ^ that's an alternative to #each-with_object({})
[18:07:08] havenwood: >> one, two, three = 1, 2, 3; %w[one two three].map { |s| [binding.local_variable_get(s), {}] }.to_h
[18:07:09] ruby[bot]: havenwood: # => {1=>{}, 2=>{}, 3=>{}} (https://eval.in/922865)
[18:07:32] havenwood: >> %w[one two three].each_with_object({}).to_h
[18:07:33] ruby[bot]: havenwood: # => {"one"=>{}, "two"=>{}, "three"=>{}} (https://eval.in/922866)
[18:11:39] Psybur_: has joined #ruby
[18:12:25] CrazyEddy: has joined #ruby
[18:13:26] RougeT430: has joined #ruby
[18:18:39] jamesaxl: has joined #ruby
[18:20:17] orbyt_: has joined #ruby
[18:24:13] milardovich: has joined #ruby
[18:26:13] stealth[]: has joined #ruby
[18:28:23] k1ltzman: has joined #ruby
[18:29:32] apeiros: has joined #ruby
[18:30:50] CrazyEddy: has joined #ruby
[18:31:42] Gabemo: has joined #ruby
[18:32:39] Vile`: has joined #ruby
[18:33:47] mikecmpbll: has joined #ruby
[18:35:31] cloaked1: has joined #ruby
[18:37:35] Psybur: has joined #ruby
[18:38:52] mostlybadfly: has joined #ruby
[18:45:04] synthroid: has joined #ruby
[18:49:00] alfiemax_: has joined #ruby
[18:50:42] sanscoeur: has joined #ruby
[18:50:49] CrazyEddy: has joined #ruby
[18:55:13] alfiemax: has joined #ruby
[18:58:38] s3nd1v0g1us: has joined #ruby
[19:01:00] JaccoP: has joined #ruby
[19:02:23] milardovich: has joined #ruby
[19:04:26] alfiemax: has joined #ruby
[19:05:40] CrazyEddy: has joined #ruby
[19:05:57] ur5us: has joined #ruby
[19:12:13] despai: has joined #ruby
[19:12:51] clemens3: has joined #ruby
[19:13:15] veeti: has joined #ruby
[19:13:39] cdg: has joined #ruby
[19:14:59] alfiemax: has joined #ruby
[19:15:58] dviola: has joined #ruby
[19:16:03] hahuang65: has joined #ruby
[19:19:04] jnollette: has joined #ruby
[19:21:40] milardovich: has joined #ruby
[19:22:59] milardovich: has joined #ruby
[19:27:31] jeffreylevesque: is there an alternate syntax to `to_h`?
[19:30:33] CrazyEddy: has joined #ruby
[19:30:36] apeiros: in passing keyword args, there's **. but that's very specific.
[19:31:03] jeffreylevesque: i'm running `@extensions.map { |s| [s, {}] }.to_h`, and getting " undefined method `to_h' for [["blah1", {}], ["blah2", {}]]:Array"
[19:31:17] apeiros: sounds like you're using an ancient ruby
[19:33:28] al2o3-cr: Hash[@extensions.map { |s| [s, {}] }]
[19:33:52] apeiros: IMO updating ruby is the better choice :D
[19:34:14] apeiros: also you forgot a *
[19:34:32] apeiros: Hash[*ary]
[19:34:59] al2o3-cr: don't need it in this example.
[19:35:14] apeiros: oh, no, you're right
[19:35:20] jeffreylevesque: going to try it thanks
[19:43:12] milardov_: has joined #ruby
[19:48:20] p0p0pr37: has joined #ruby
[19:48:20] p0p0pr37: has joined #ruby
[19:51:09] jobewan: has joined #ruby
[19:55:07] m27frogy: has joined #ruby
[19:55:38] workmad3: has joined #ruby
[19:57:06] sameerynho: has joined #ruby
[19:57:54] veeti: has joined #ruby
[19:59:07] claudiuinberlin: has joined #ruby
[20:02:01] m27frogy: has joined #ruby
[20:02:41] dviola: has joined #ruby
[20:04:14] s2013: has joined #ruby
[20:16:00] m27frogy: has joined #ruby
[20:20:53] CrazyEddy: has joined #ruby
[20:21:07] biox: has joined #ruby
[20:22:51] mtkd: has joined #ruby
[20:23:51] al2o3-cr: has joined #ruby
[20:24:27] amperry: has joined #ruby
[20:26:43] amperry: hi folks, asked this over on #RubyOnRails but I don't know if it's truly rails-specific: I'm getting an error running tests with rspec and FactoryBot, that one of my factories is not registered. Is there a way to find out *why* a factory was not registered?
[20:27:03] eckhardt: has joined #ruby
[20:31:03] mikecmpb_: has joined #ruby
[20:33:39] orbyt_: has joined #ruby
[20:36:31] raynold: has joined #ruby
[20:37:26] mikecmpbll: has joined #ruby
[20:37:33] raynold: ahh it's a wonderful day
[20:38:50] kapil___: has joined #ruby
[20:38:58] cagomez: has joined #ruby
[20:41:39] dviola: has left #ruby: ("WeeChat 2.0")
[20:42:09] CrazyEddy: has joined #ruby
[20:42:45] dviola: has joined #ruby
[20:43:14] amperry: raynold: why do you say that?
[20:46:14] claudiuinberlin: has joined #ruby
[20:53:43] gizmore|3: has joined #ruby
[20:55:01] gizmore|2: has joined #ruby
[20:56:16] synthroid: has joined #ruby
[20:56:28] gizmore3: has joined #ruby
[20:57:03] pastorinni: has joined #ruby
[20:57:54] gizmore|4: has joined #ruby
[20:59:14] gizmore: has joined #ruby
[20:59:45] amperry: has left #ruby: ("ERC (IRC client for Emacs 24.5.1)")
[21:05:07] sammi`: has joined #ruby
[21:07:32] gizmore|2: has joined #ruby
[21:08:19] nginxxx: has joined #ruby
[21:08:43] nginxxx: When i write require 'threads' then it says "false"
[21:08:50] nginxxx: But its installed
[21:09:06] nginxxx: Successfully installed thread-0.2.2 Parsing documentation for thread-0.2.2 Done installing documentation for thread after 0 seconds 1 gem installed
[21:09:11] nginxxx: Could someone help me?
[21:09:37] Papierkorb: nginxxx: require returns true if it wasn't loaded before, and returns false if it was already loaded. If requiring fails, it raises an LoadError.
[21:09:51] gizmore|3: has joined #ruby
[21:10:07] cagomez: has joined #ruby
[21:10:31] CrazyEddy: has joined #ruby
[21:11:04] VladGh: has joined #ruby
[21:11:36] veeti: has joined #ruby
[21:11:58] conta1: has joined #ruby
[21:12:16] krawchyk: has joined #ruby
[21:17:08] hahuang65: has joined #ruby
[21:22:01] VladGh: has joined #ruby
[21:27:17] CrazyEddy: has joined #ruby
[21:29:16] mistergibson: anyone here use ruby-qml?
[21:32:21] zacts: has joined #ruby
[21:35:35] johno84: has joined #ruby
[21:36:36] workmad3: has joined #ruby
[21:37:13] cagomez: has joined #ruby
[21:38:43] rwb-averon: has joined #ruby
[21:39:44] jenrzzz: has joined #ruby
[21:39:45] jenrzzz: has joined #ruby
[21:43:01] claudiuinberlin: has joined #ruby
[21:45:23] QualityAddict: has joined #ruby
[21:47:35] tomphp: has joined #ruby
[21:48:31] jeffreylevesque_: has joined #ruby
[21:52:04] jeffreylevesque_: i'm getting "expected ':' in object at '=>{}, "two"=>{},"
[21:52:27] jeffreylevesque_: i guess i need Hash[] to convert to a json
[21:52:42] jeffreylevesque_: my code: Hash[@extensions.map { |s| [s, {}] }]
[21:53:14] jeffreylevesque_: extensions = ['one', 'two', 'three']
[21:53:19] pharma_joe: has joined #ruby
[21:54:38] havenwood: >> %w[one two three].each_with_object({}) { |s, h| h[s] = {} } # jeffreylevesque_
[21:54:39] ruby[bot]: havenwood: # => {"one"=>{}, "two"=>{}, "three"=>{}} (https://eval.in/923009)
[21:55:51] jeffreylevesque_: is it possible to return: {"one":{}, "two":{}, "three":{}}
[21:56:01] havenwood: jeffreylevesque_: #to_json
[21:56:06] jeffreylevesque_: my function returns it as a string
[21:56:11] jeffreylevesque_: so, i'm going to load it
[21:56:21] jeffreylevesque_: is there an alternative to `to_json`
[21:56:31] `derpy: No results
[21:56:35] `derpy: http://ruby-doc.org/stdlib-2.4.1/libdoc/json/rdoc/JSON.html
[21:57:22] havenwood: >> require 'json'; JSON.dump %w[one two three].each_with_object({}) { |s, h| h[s] = {} }
[21:57:23] ruby[bot]: havenwood: # => "{\"one\":{},\"two\":{},\"three\":{}}" (https://eval.in/923010)
[21:57:30] apeiros: jeffreylevesque_: again, you're using an ancient ruby
[21:57:41] jeffreylevesque_: yeah, i'm using ruby from puppet
[21:57:48] jeffreylevesque_: doing some round the bush things
[21:58:02] apeiros: there's no "ruby from puppet"
[21:58:06] apeiros: puppet uses ruby
[21:58:19] apeiros: update your ruby and you have a new ruby in puppet too
[22:00:27] jeffreylevesque_: i forgot to put `require 'json'`
[22:00:33] jeffreylevesque_: hopefully .to_json works
[22:00:57] veeti: has joined #ruby
[22:01:36] tomphp: has joined #ruby
[22:09:34] eckhardt: has joined #ruby
[22:13:13] CrazyEddy: has joined #ruby
[22:15:43] cadillac_: has joined #ruby
[22:20:27] jnyw: has joined #ruby
[22:20:42] orbyt_: has joined #ruby
[22:27:40] brian_penguin: has joined #ruby
[22:30:54] spk: has joined #ruby
[22:34:02] mtkd: has joined #ruby
[22:35:30] neo95: has joined #ruby
[22:35:54] selim: has joined #ruby
[22:39:16] CrazyEddy: has joined #ruby
[22:42:11] workmad3: has joined #ruby
[22:53:08] tfitts: I'm wondering if there's a way to have a class that accepts enumerable methods and calls them on a one of the class methods? Right now I have a report_list that is just an array of hashes. I'm trying to convert it to a ReportList class that lets me reload the report and do a few other things. The report list has an array of what are now Report classes that are similar to the hashes but also have a bit more
[22:53:08] tfitts: functionality. I'm wondering if I can make it so called ReportList.new.each(&:do_something) can call do something on each of the reports, and also so ReportList.new.first will give me the first Report
[22:53:48] k0mpa: has joined #ruby
[22:59:12] neo95: has joined #ruby
[23:02:36] baweaver: tfitts: delegators mainly, either that or define each on the class as each for the collection and include Enumerable
[23:02:50] baweaver: SimpleDelegator is the easiest
[23:03:01] tfitts: ok, I'll check into that.
[23:10:00] cdg: has joined #ruby
[23:15:41] milardovich: has joined #ruby
[23:17:57] hahuang65: has joined #ruby
[23:17:57] jenrzzz: has joined #ruby
[23:17:57] jenrzzz: has joined #ruby
[23:20:16] k0mpa: has joined #ruby
[23:20:21] CrazyEddy: has joined #ruby
[23:23:04] cdg: has joined #ruby
[23:24:47] bmurt: has joined #ruby
[23:25:34] s3nd1v0g1us: has joined #ruby
[23:29:05] alfiemax: has joined #ruby
[23:32:19] konsolebox: has joined #ruby
[23:34:27] cdg: has joined #ruby
[23:34:33] jeffreylevesque: has joined #ruby
[23:36:37] kies: has joined #ruby
[23:37:08] CrazyEddy: has joined #ruby
[23:43:14] _aeris_: has joined #ruby
[23:44:16] cdg_: has joined #ruby
[23:53:16] shinnya: has joined #ruby
[23:55:30] CrazyEddy: has joined #ruby
[23:57:15] s3nd1v0g1us: has joined #ruby