« Back to channel list

#ruby - 18 November 2018

« Back 1 day Forward 1 day »
[00:01:32] bmurt: has joined #ruby
[00:03:49] sgen: has joined #ruby
[00:06:41] Exuma: has joined #ruby
[00:10:25] alicef: has joined #ruby
[00:35:36] cow[moo]: has joined #ruby
[00:36:11] nicesignal: has joined #ruby
[00:36:53] smutnysy1: has joined #ruby
[00:40:13] smutnysy1: has joined #ruby
[00:48:34] paulscoder: has joined #ruby
[00:51:55] queip: has joined #ruby
[00:59:24] alicef: has joined #ruby
[01:04:41] DTZUZO: has joined #ruby
[01:07:17] galaxie: has joined #ruby
[01:09:56] galaxie: Should I take this seriously anymore? https://sakurity.com/blog/2015/02/28/openuri.html
[01:10:38] galaxie: Is there a way to call OpenURI#open directly? It's listed as a private method.
[01:12:11] arescorpio: has joined #ruby
[01:33:28] woodruffw: galaxie: `require 'open-uri'; open('https://whatever')` doesn't work?
[01:35:04] Exuma: has joined #ruby
[01:38:23] galaxie: woodruff: It does, but RuboCop says it's a security hazard and while I don't think it might make a difference, I'd rather not get those annoying messages when they aren't relevant.
[01:47:29] DTZUZO: has joined #ruby
[01:47:30] queip: has joined #ruby
[01:48:38] lupine: has joined #ruby
[01:50:01] nchambers: what about net/http?
[01:52:13] galaxie: nchambers: It's an idea, but it's also more low-level. I'm a bit lazy.
[01:52:49] nchambers: fwiw, i cheat and use this: https://jhawthorn.github.io/curl-to-ruby/
[02:00:40] galaxie: How would I monkeypatch rand() so that every object uses the new method? I'm trying to monkeypatch Kernel#rand and that works but it does not carry over to rand().
[02:28:06] knight33_: has joined #ruby
[02:31:02] elphe: has joined #ruby
[02:45:18] jgpawletko: has joined #ruby
[02:48:24] woodruffw: galaxie: yeah, that's a problem with `open-uri` as a whole. as nchambers mentioned, net/http is probably the right way to go
[02:49:35] woodruffw: FWIW, using `net/http` is as simple as this: `Net::HTTP.get(URI(your_url))`
[02:49:48] woodruffw: that returns a `String` containing just the response body
[02:50:38] woodruffw: ref for open-uri being generally dangerous: https://sakurity.com/blog/2015/02/28/openuri.html
[02:52:05] queip: has joined #ruby
[02:57:49] galaxie: woodruffw: Hmm, OK. How easy to set a user-agent?
[03:00:47] woodruffw: galaxie: for that, you'll need to create a `Net::HTTP::Get` object, i think. that object can then be treated like a hash to add headers, e.g. `foo['X-Whatever'] = 'bar'`
[03:01:03] woodruffw: this seems to cover it: https://stackoverflow.com/questions/44839503/ruby-send-get-request-with-headers
[03:01:36] woodruffw: in terms of personal choice, that's where i'd switch to `httparty` or another gem for simplicity, unless it's just a short script
[03:07:31] elphe: has joined #ruby
[03:09:22] jetchisel: has joined #ruby
[03:15:20] elphe: has joined #ruby
[03:21:09] _whitelogger: has joined #ruby
[03:21:09] jrhorn424: has joined #ruby
[03:22:57] evdubs_: has joined #ruby
[03:37:33] arescorpio: has joined #ruby
[03:41:23] tag: has joined #ruby
[03:45:41] arescorpio: has joined #ruby
[03:47:34] howdoicomputer: has joined #ruby
[03:50:09] Arkantos: has joined #ruby
[03:59:52] Exuma: has joined #ruby
[04:04:36] Exuma: has joined #ruby
[04:09:39] braincrash: has joined #ruby
[04:10:53] awkwords: has joined #ruby
[04:15:47] cd: has joined #ruby
[04:19:43] JusticeFries: has joined #ruby
[04:19:55] JusticeFries: has left #ruby: ()
[04:40:29] nchambers: So I wrote an each method for my class, but I'd like to return an enumerator if no block is given. Is there a good article or doc on how to define an enumerator for your class?
[04:45:11] _whitelogger: has joined #ruby
[04:50:12] havenwood: nchambers: return enum_for __method__ unless block_given?
[04:50:20] havenwood: nchambers: https://gist.github.com/havenwood/236d387827c16695b55a7799770d8da1
[04:51:08] havenwood: nchambers: If you know the size of the Enumerator, you might want to also provide a lazily calculated size to your enum.
[04:51:17] nchambers: great thank you!
[04:51:25] nchambers: and no i don't :c
[04:52:09] nchambers: what is enum_for?
[04:52:19] havenwood: nchambers: an alias for #to_enum
[04:53:07] havenwood: nchambers: and `__method__` is just `:each`
[04:53:23] havenwood: nchambers: just a little more resilient to method name changes
[04:53:51] havenwood: no prob, you're welcome!
[04:54:23] queip: has joined #ruby
[04:55:45] havenwood: for a lazily calculated size of 2, for example: return enum_for(__method__) { 2 } unless block_given?
[05:00:10] _whitelogger: has joined #ruby
[05:02:07] woodruffw: woah, i had no idea __method__ or __callee__ existed
[05:09:13] ivanskie: has joined #ruby
[05:11:19] Exuma: has joined #ruby
[05:11:53] elphe: has joined #ruby
[05:21:29] RougeR: has joined #ruby
[05:28:32] MoritaShinobu: has joined #ruby
[05:33:42] luminous: has joined #ruby
[05:39:18] BTRE: has joined #ruby
[05:40:17] irdr: has joined #ruby
[05:44:42] patr0clus: has joined #ruby
[05:48:56] queip: has joined #ruby
[05:56:18] ivanskie: has joined #ruby
[05:56:50] FrankD: has joined #ruby
[06:06:10] _whitelogger: has joined #ruby
[06:26:23] elphe: has joined #ruby
[06:29:12] rippa: has joined #ruby
[06:48:33] queip: has joined #ruby
[06:57:10] _whitelogger: has joined #ruby
[06:58:19] kapil____: has joined #ruby
[07:02:12] elphe: has joined #ruby
[07:07:00] reber: has joined #ruby
[07:16:39] conta: has joined #ruby
[07:18:22] whysthatso: has joined #ruby
[07:19:48] elphe: has joined #ruby
[07:22:17] yohji: has joined #ruby
[07:30:52] reber__: has joined #ruby
[07:53:44] howdoicomputer: has joined #ruby
[07:55:47] ur5us: has joined #ruby
[08:25:52] dellavg_: has joined #ruby
[08:30:36] Dbugger: has joined #ruby
[08:33:36] phaul: has joined #ruby
[08:45:56] baweaver: All six parts are done, and Reducing Enumerable has now been made into a series of text posts. Enjoy: https://medium.com/@baweaver/reducing-enumerable-part-one-the-journey-begins-ddc1d4108490
[08:47:02] havenwood: baweaver: Great posts!
[08:57:39] lomex: has joined #ruby
[09:08:27] yxhuvud: has joined #ruby
[09:10:30] elphe: has joined #ruby
[09:21:49] venmx: has joined #ruby
[09:36:53] apparition: has joined #ruby
[09:38:20] zapata: has joined #ruby
[09:45:57] gix: has joined #ruby
[09:46:47] lxsameer: has joined #ruby
[09:47:55] RougeR: has joined #ruby
[10:00:35] yohji: has joined #ruby
[10:01:50] MoritaShinobu: has joined #ruby
[10:04:21] hays: has joined #ruby
[10:14:02] wildermind: has joined #ruby
[10:14:47] elphe: has joined #ruby
[10:36:25] rubydoc: has joined #ruby
[10:37:51] MoritaShinobu: has joined #ruby
[10:51:58] queip: has joined #ruby
[11:04:04] dbugger_: has joined #ruby
[11:13:04] jetchisel: has joined #ruby
[11:18:23] conta: has joined #ruby
[11:32:46] pskosinski: has joined #ruby
[11:49:22] clemens3: has joined #ruby
[11:53:36] im0nde: has joined #ruby
[11:56:08] whysthatso: has joined #ruby
[11:58:38] desperek: has joined #ruby
[11:59:13] govg: has joined #ruby
[12:02:34] Inline: has joined #ruby
[12:05:08] AJA4350: has joined #ruby
[12:14:08] whysthatso: has joined #ruby
[12:28:45] lomex: has joined #ruby
[12:35:03] LinuxKnight: has joined #ruby
[12:50:29] Inline: has joined #ruby
[12:51:11] queip: has joined #ruby
[12:53:45] kapil____: has joined #ruby
[12:55:14] phaul: hi kapil____
[12:55:19] yxhuvud: has joined #ruby
[12:55:42] kapil____: i am using begin rescue myfunc() end
[12:57:12] kapil____: sorry. i am using `begin ..rescue..myfunc()..rescue..end`
[12:57:34] kapil____: but second rescue cant catch error if myfunc() fails.
[12:59:03] canton7: indeed, because it doesn't appear between the 'begin' and the 'rescue'
[12:59:16] canton7: if you want to catch errors from it, put it in its own begin/rescue block
[12:59:54] kapil____: canton7: thanks
[13:00:36] kapil____: what multiple rescue statements for?
[13:01:12] canton7: catching different sorts of errors
[13:01:48] canton7: 'rescue OneTypeOfException' ... 'rescue AnotherTypeOfException' ...
[13:13:06] dbugger__: has joined #ruby
[13:16:20] Inline: has joined #ruby
[13:18:49] dkmueller: has joined #ruby
[13:34:38] Guest24308: has joined #ruby
[13:38:35] roshanavand: has joined #ruby
[13:51:18] queip: has joined #ruby
[13:57:12] elphe: has joined #ruby
[14:10:45] BTRE: has joined #ruby
[14:18:10] _whitelogger: has joined #ruby
[14:19:56] whysthatso: has joined #ruby
[14:20:27] joast: has joined #ruby
[14:21:36] im0nde: has joined #ruby
[14:44:19] reber: has joined #ruby
[14:45:41] akem: has joined #ruby
[14:52:05] pabs: has joined #ruby
[14:55:42] conta: has joined #ruby
[14:57:50] akem: has joined #ruby
[15:00:52] akem: has joined #ruby
[15:12:13] maximjaffe: has joined #ruby
[15:16:46] paulscoder: has joined #ruby
[15:19:15] whysthatso: has joined #ruby
[15:26:45] elphe: has joined #ruby
[15:34:09] desperek: has joined #ruby
[15:34:35] houhoulis: has joined #ruby
[15:36:54] kaleido: has joined #ruby
[15:41:05] sgen: has joined #ruby
[15:48:30] queip: has joined #ruby
[15:53:24] luminous: has joined #ruby
[15:59:20] ptx0: has joined #ruby
[16:04:45] universa1: has joined #ruby
[16:11:43] Sembei: has joined #ruby
[16:18:43] Puffball: has joined #ruby
[16:19:22] yohji: has joined #ruby
[16:21:51] yxhuvud: has joined #ruby
[16:32:58] ChatCodingLab: has joined #ruby
[16:33:00] akem: has joined #ruby
[16:35:57] ivanskie: has joined #ruby
[16:36:26] jetchisel: has joined #ruby
[16:42:49] bairyn: has joined #ruby
[16:44:42] jetchisel: has joined #ruby
[16:44:47] akem: has joined #ruby
[16:46:41] za1b1tsu: has joined #ruby
[16:47:43] kn-928: has joined #ruby
[16:49:38] queip: has joined #ruby
[16:51:10] akem: has joined #ruby
[16:51:31] clemens3: has joined #ruby
[16:53:13] lomex: has joined #ruby
[16:55:24] Nicmavr: has joined #ruby
[16:55:50] akaiiro: has joined #ruby
[17:00:40] Puffball: has joined #ruby
[17:02:22] Tom-_: has joined #ruby
[17:02:53] Tom-_: is learning ruby from learnrubythehardway.org a good idea?
[17:05:02] kaleido: the generic, but still accurate, answer is that yes it will help you learn the basics just as well as any other means.
[17:07:42] pabs: has joined #ruby
[17:15:59] jordila: has joined #ruby
[17:20:15] jaddison: has joined #ruby
[17:22:18] Tom-_: that's quite good enough for me, thanks very much!
[17:22:21] bendersteed: has joined #ruby
[17:27:09] ua: has joined #ruby
[17:33:03] jthomas: has joined #ruby
[17:34:01] jordila: absolute ruby beginner here, trying to get to know Nil ... on the following snippet at https://pastebin.com/Ly2hCVfC , what __ should be substituted for ?
[17:34:01] ruby[bot]: jordila: we in #ruby do not like pastebin.com, it loads slowly for most, has ads which are distracting and has terrible formatting. Please use https://gist.github.com
[17:38:19] jordila: sure ... , when trying to get to know Nil ... on the following snippet at https://gist.github.com/jordila/98fd2dd291889581a8418750c43765f8 , what __ should be substituted for in order to the function to become true ?
[17:38:24] whysthatso: has joined #ruby
[17:40:13] nchambers: &>> nil.is_a? Object
[17:40:16] rubydoc: # => true (https://carc.in/#/r/5k9b)
[17:40:48] nchambers: its just trying to show you that nil is an object of (I think) NilClass
[17:41:21] nchambers: versus something like None in python, or NULL in C, which effectively means "no data" and is not an object
[17:42:56] jgpawletko: has left #ruby: ()
[17:49:51] phaul: ah, good old ((void*)0) :)
[17:50:06] phaul: so glad those days are behind me :)
[17:52:56] jordila: nchambers, umh.. so may i substitute '__' for '&>> ' ?
[17:53:16] nchambers: &>> is just to tell the bot to run the following code
[17:53:27] nchambers: what is the result of nil.is_a?(Object)
[17:53:33] nchambers: and what are you comparing against?
[17:53:43] queip: has joined #ruby
[17:53:55] ivanskie: has joined #ruby
[17:54:15] Inline: has joined #ruby
[17:56:22] al2o3-cr: jordila: you substitute `__` with true.
[18:00:05] jordila: ACTION ... can continue the ruby path-to-enlightenment, by substituting `__` with true as long as current koan is satisfied 
[18:01:00] phaul: now .. that's what you call enlightenment
[18:01:20] nchambers: i should probably finish my ruby koans :/
[18:01:22] ivanskie: has joined #ruby
[18:04:16] jordila: ACTION loves #ruby 
[18:07:54] conta: has joined #ruby
[18:08:08] za1b1tsu: has joined #ruby
[18:10:24] Inline: has joined #ruby
[18:11:25] lomex: has joined #ruby
[18:14:30] dkmueller: has joined #ruby
[18:19:51] roshanavand: has joined #ruby
[18:21:42] RougeR: has joined #ruby
[18:25:15] dviola: has joined #ruby
[18:32:48] raul782: has joined #ruby
[18:35:58] lomex: has joined #ruby
[18:38:52] jordila: has joined #ruby
[18:39:35] conta: has joined #ruby
[18:44:20] patr0clus: has joined #ruby
[18:45:16] ivanskie: has joined #ruby
[18:50:10] kapil____: has joined #ruby
[18:51:19] dkmueller: has joined #ruby
[18:52:54] conta: has joined #ruby
[18:54:39] ptx0: has joined #ruby
[19:10:07] segy: has joined #ruby
[19:11:14] jordila: when trying to get to know a little bit more on Nil ... on the following snippet at https://dpaste.de/ZsMV , what __ should be substituted for in order to the function to become true ?
[19:11:35] phil80: has joined #ruby
[19:20:38] patr0clus: has joined #ruby
[19:24:59] phaul: jordila: make it something - anyting that would make it run past syntax errors. change __ to any object you like: 1, 'a', nil, [13] etc. then run it again and observe.
[19:30:20] jordila: phaul, tried 'nil' , unsuccesfully
[19:32:22] elphe: has joined #ruby
[19:35:32] phaul: did you get different output? What did it say?
[19:37:02] jordila: Koans application says ... 'Expected nil to equal NoMethodError ' ... but i cannot (yet) see the light .
[19:37:34] jordila: Eve when substituting '__' by 'NoMethodError' ?
[19:37:58] phaul: yeah. that should get you further
[19:38:45] phaul: always read what it says. and try to make sense of it..
[19:40:21] nchambers: has joined #ruby
[19:41:14] weaksauce: has joined #ruby
[19:42:22] clemens3: has joined #ruby
[19:48:42] bmurt: has joined #ruby
[19:51:40] Dbugger: has joined #ruby
[19:55:00] queip: has joined #ruby
[19:55:35] jordila: when substituting '__' for 'NoMethodError' i cannot (yet) see the light.
[20:00:39] phil80: has joined #ruby
[20:02:15] aufi: has joined #ruby
[20:03:22] Tom-_: has joined #ruby
[20:10:25] phaul: jordila: 'NoMethodError' is different from NoMethodError. Notice the 'marks'.
[20:11:11] akaiiro: has joined #ruby
[20:11:47] phaul: one is a constant pointing to some object. Typically a class or module, but sometimes, something else. The other with single quotes is a string
[20:12:55] elphe: has joined #ruby
[20:13:43] phaul: NoMethodError is a class in this case which denotes the error of method on object is non-existent
[20:13:50] phaul: &ri NoMethodError
[20:13:50] rubydoc: https://ruby-doc.org/core-2.5.3/NoMethodError.html
[20:17:30] thejs: has joined #ruby
[20:19:40] relyks: has joined #ruby
[20:24:16] relyks: has joined #ruby
[20:29:02] BH23: has joined #ruby
[20:29:58] jaddison: has joined #ruby
[20:32:58] ur5us: has joined #ruby
[20:35:33] sgen: has joined #ruby
[20:41:52] sheepman: has joined #ruby
[20:42:51] venmx: has joined #ruby
[20:43:13] Guest24308: has joined #ruby
[20:47:28] elphe: has joined #ruby
[20:53:10] lunarkitty7: has joined #ruby
[20:54:25] paulscoder: has joined #ruby
[20:59:21] dviola: has joined #ruby
[20:59:50] daemonwrangler: has joined #ruby
[21:02:28] akaiiro: has joined #ruby
[21:06:34] Exuma: has joined #ruby
[21:08:38] beeman: has joined #ruby
[21:16:55] paulscoder: has joined #ruby
[21:19:02] nchambers: is there something like Object#class expcet it outputs the basename of the class? I've got a class named Raspberry::Type::Lambda and I'd like to just get Lambda
[21:19:44] nchambers: other than foo.class.name.split("::")[-1]
[21:23:26] phaul: there aretwo distinct things in play. scope nesting and inheritance
[21:23:48] phaul: :: separates nesting. and it's independent of inheritance
[21:24:01] phaul: &ri nesting
[21:24:01] rubydoc: https://ruby-doc.org/core-2.5.3/Module.html#method-c-nesting
[21:24:50] RougeR: has joined #ruby
[21:25:17] phaul: I'm not sure if you referred to inheritance at all, but basename sounded like base class...
[21:26:34] phaul: you could get #nesting.last ?
[21:27:00] phaul: not sure if it always does whatyou need..
[21:29:01] nchambers: thanks phaul, I'll check those out
[21:33:07] phaul: nchambers: actually it doesn't do what you need. nm, sorry, I don't know better way than what you said...
[21:37:38] nchambers: its just cosmetic anyways
[21:42:35] phaul: also there is a gotcha with the difference between module A; module B; end; end; vs module A::B; end; #nesting shows that these are different, I did some writeup of what I found here https://github.com/phaul/ruby_101/blob/master/content/book.md#lexical-scope-nesting
[21:46:43] queip: has joined #ruby
[21:54:48] GodFather: has joined #ruby
[22:03:20] jordila: phaul , indeed ... with NoMethodError class came the light
[22:04:48] crankharder: has joined #ruby
[22:07:58] themsay: has joined #ruby
[22:19:17] crankhar1er: has joined #ruby
[22:21:22] phaul: has joined #ruby
[22:35:15] venmx: has joined #ruby
[22:41:09] jaddison: has joined #ruby
[22:43:38] darthfork: has joined #ruby
[22:44:36] paulscoder: has joined #ruby
[22:48:48] queip: has joined #ruby
[22:52:03] roshanavand: has joined #ruby
[22:52:10] venmx: has joined #ruby
[22:54:12] seabee: has joined #ruby
[22:54:20] jordila: has left #ruby: ()
[22:58:48] TheBloke: has joined #ruby
[23:00:33] ausmat: has joined #ruby
[23:06:33] tdy: has joined #ruby
[23:13:08] jhass: has joined #ruby
[23:13:42] patr0clus: has joined #ruby
[23:20:00] zapata: has joined #ruby
[23:32:54] ivanskie: has joined #ruby
[23:37:54] DTZUZO: has joined #ruby
[23:41:15] jcalla: has joined #ruby
[23:48:50] dviola: has joined #ruby
[23:48:51] queip: has joined #ruby
[23:56:46] jcalla: has joined #ruby
[23:58:06] bmurt: has joined #ruby