« Back to channel list

#ruby - 07 January 2019

« Back 1 day Forward 1 day »
[00:00:30] cnsvc: has joined #ruby
[00:16:40] duderonomy: has joined #ruby
[00:23:29] hutch: has joined #ruby
[00:24:59] AJA4351: has joined #ruby
[00:26:40] ur5us: has joined #ruby
[00:29:18] AJA4351: has joined #ruby
[00:31:44] AJA4351: has joined #ruby
[00:31:54] ur5us: has joined #ruby
[00:32:36] EXCHGR: has joined #ruby
[00:35:33] AJA4350: has joined #ruby
[00:38:23] AJA4351: has joined #ruby
[00:40:54] conta: has joined #ruby
[00:42:10] AJA4351: has joined #ruby
[00:44:59] AJA4350: has joined #ruby
[00:45:45] tdy: has joined #ruby
[00:47:20] AJA4351: has joined #ruby
[00:50:09] drale2k_: has joined #ruby
[01:05:27] davidw_: has joined #ruby
[01:12:29] johnny56_: has joined #ruby
[01:23:02] drale2k_: has joined #ruby
[01:49:28] akem: has joined #ruby
[02:00:01] akem: has joined #ruby
[02:13:22] johnny56_: has joined #ruby
[02:17:47] JJonah: is there any Array builtin that _disallows_ negative indexes? `[]` and `fetch` both interpret negative values as counting from the right...
[02:18:36] code_zombie: has joined #ruby
[02:19:09] mozzarella: why do you w ant that?
[02:29:57] davidw_: has joined #ruby
[02:45:00] tdy: has joined #ruby
[02:46:23] r29v: has joined #ruby
[02:54:43] esrse: has joined #ruby
[02:58:02] fiachetti: has joined #ruby
[03:07:33] matsaman: has joined #ruby
[03:09:02] uplime: has joined #ruby
[03:20:52] AndreYuhai: has joined #ruby
[03:22:41] AndreYuhai: Hello how can I write the xPath for this HTML https://paste.ofcode.org/a2egTxG6tEeKP8QFmaT3qJ I want to get the a tag. Is there any other way besides "//section[@class='pv-contact-info__contact-type ci-email']/div/a" ?
[03:22:57] AndreYuhai: I mean any shorter or better way
[03:23:05] Azure: has joined #ruby
[03:24:12] matsaman: has joined #ruby
[03:30:19] tdy: has joined #ruby
[03:33:03] cschneid: has joined #ruby
[03:33:58] rkazak: has joined #ruby
[03:37:19] cthulchu: has joined #ruby
[03:37:29] cthulchu: guys. using #{} is not formatting, right?
[03:37:34] cthulchu: what do you call it?
[03:37:46] cthulchu: I'm trying to find something like that in py now
[03:41:08] tiff: has joined #ruby
[03:45:28] mozzarella: cthulchu: string interpolation?
[03:50:01] hutch: has joined #ruby
[04:04:43] conta: has joined #ruby
[04:08:05] cschneid: has joined #ruby
[04:08:32] braincrash: has joined #ruby
[04:17:39] dellavg_: has joined #ruby
[04:25:15] duderonomy: has joined #ruby
[04:25:57] Nicmavr: has joined #ruby
[04:57:03] faraazahmad: has joined #ruby
[05:00:04] nowhere_man: has joined #ruby
[05:07:28] agent_white: has joined #ruby
[05:08:17] cnsvc: has joined #ruby
[05:19:19] hutch: has joined #ruby
[05:38:49] solocshaw: has joined #ruby
[05:48:05] marmotini_: has joined #ruby
[05:48:50] marmotini_: has joined #ruby
[05:49:13] marmotini: has joined #ruby
[06:14:45] tdy: has joined #ruby
[06:19:06] cschneid: has joined #ruby
[06:19:24] conta: has joined #ruby
[06:22:06] marmotini_: has joined #ruby
[06:23:46] nowhere_man: has joined #ruby
[06:27:56] marmotini_: has joined #ruby
[06:29:20] segy: has joined #ruby
[06:40:09] aupadhye_: has joined #ruby
[06:40:10] aupadhye: has joined #ruby
[06:42:10] Dbugger: has joined #ruby
[06:50:35] cschneid: has joined #ruby
[06:57:07] comet23: has joined #ruby
[06:57:12] comet23: is there a way to convert ">" to >
[06:58:26] dbugger_: has joined #ruby
[07:04:01] ruby[bot]: it seems like you are asking for a specific solution to a problem, instead of asking about your problem. This often leads to bad solutions and increases frustration for you and those trying to help you. More: http://meta.stackexchange.com/a/66378
[07:06:18] johnny56_: has joined #ruby
[07:16:16] comet23: baweaver: basically i want to refactor my code and the only logical solution i came up with is if there was a way to convert string <> signs back to their respective signs
[07:16:30] baweaver: What's your code?
[07:16:51] baweaver: because chances are high you don't need to do that.
[07:16:59] comet23: https://repl.it/repls/RegalFrightenedGlitch
[07:17:45] baweaver: So you're trying to rotate an array?
[07:17:55] comet23: the code works fine
[07:18:09] baweaver: First note: Ruby has a rotate function
[07:18:17] comet23: it's a coding exercise
[07:18:28] baweaver: Second note: rotated_arr = arr does not make a clone, it points to the same array
[07:20:05] comet23: so i have to iterate through the original array and then append its contents to it? or will that still not make a clone?
[07:21:17] baweaver: I'd use each_with_index and just make a new array.
[07:23:28] khomesh24: has left #ruby: ("Leaving")
[07:26:02] aufi: has joined #ruby
[07:28:00] comet23: is there a way to make it so i don't have to have two while loops?
[07:28:54] comet23: i would like to use a conditional > operator that inverts based on the offset being greater or lower than 0
[07:29:09] aupadhye: has joined #ruby
[07:29:59] baweaver: What if I told you that this is possible with a oneliner?
[07:30:09] baweaver: The trick is to use modulus.
[07:30:16] comet23: i'm really bad at math
[07:30:31] comet23: but yes i would like to see it
[07:30:34] baweaver: Do you know what that is?
[07:30:38] comet23: maybe it'll make me that much better at math
[07:30:43] comet23: i know what it is and how it works
[07:30:43] baweaver: I'm horrid at math too
[07:30:51] comet23: i'm just really bad at using math
[07:31:00] comet23: or coming up with ideas where to use modulus
[07:31:17] baweaver: What happens when you add a negative number?
[07:31:30] comet23: it subtracts
[07:31:33] baweaver: Let's take a look at our base array: [1, 2, 3]
[07:31:52] baweaver: If we were to rotate it by -1, you could say it'd be [2, 3, 1]
[07:32:26] baweaver: What's the index of 1 before the rotation?
[07:32:51] comet23: you mean the contents?
[07:32:56] comet23: the contents of index 1?
[07:33:11] leftylink: which index contains the number 1
[07:33:17] baweaver: Let's switch the base array
[07:33:17] baweaver: It's now ['a', 'b', 'c']
[07:33:29] baweaver: what's the index of 'a' before and after a rotation of -1?
[07:33:49] comet23: 0 and .length - 1 or -1
[07:34:07] baweaver: What happens if you use modulo on a negative number?
[07:34:19] baweaver: Give it a try in a repl
[07:34:20] comet23: i honestly have never done that before
[07:34:45] baweaver: Describe what modulo does to me real quick
[07:34:48] comet23: is the negative number the divisor or the dividend?
[07:34:54] faraazahmad_: has joined #ruby
[07:35:33] comet23: it divides numbers evenly, if it can't divide evenly it will tell you how many numbers are
[07:35:47] comet23: left before it could have been divided evenly
[07:35:57] baweaver: So the reason you have two while loops?
[07:36:10] comet23: one while loop to rotate right and the other to rotate left
[07:36:32] baweaver: Adding negative numbers :)
[07:36:39] baweaver: you only need to rotate once
[07:36:45] baweaver: and in one "direction" so to speak
[07:37:07] comet23: the weird thing is, i didn't use the modulo operator
[07:37:26] comet23: i just started rotating it at first, but the negative test cases were failing because it was rotating it the wrong way
[07:37:44] comet23: for a negative offset i mean
[07:38:25] comet23: could you please give me an example of using % with a negative number
[07:38:52] baweaver: Have you tried in your REPL?
[07:39:00] comet23: i tried 5 % -1 and -1 % 5 and -1 % -1
[07:39:17] baweaver: What did that second one give you?
[07:39:17] comet23: i'm not sure i'm understanding what you're saying
[07:39:26] rubydoc: # => 2 (https://carc.in/#/r/5xuy)
[07:39:31] comet23: that's clever
[07:39:38] comet23: like really clever
[07:39:45] baweaver: So if i + offset is -1...
[07:39:58] baweaver: You now have the index of the end of the array
[07:40:21] baweaver: So 0 offset by -1 is -1, meaning it'd go at the end of the array
[07:40:32] baweaver: See if you can figure out how to code that in
[07:40:38] comet23: thank you :D
[07:40:43] baweaver: I'd suggest taking 3-5 lines
[07:40:49] baweaver: 1 is just showing off to make it compact
[07:42:25] comet23: i still haven't tested it yet
[07:42:35] comet23: 3 is referring to the number of items, correct?
[07:44:27] comet23: https://repl.it/repls/SuburbanDemandingWrapper
[07:45:17] baweaver: Here's the compact version: https://repl.it/@baweaver/IllustriousPristineClients
[07:46:00] comet23: will i be seeing a lot of code like that professionally>
[07:46:14] Puffball: has joined #ruby
[07:46:17] leftylink: save a line by changing the reduce to a .with_object
[07:46:24] baweaver: You'd be far far more likely to see `array.rotate(1)`
[07:46:39] baweaver: with_index makes the arg order kinda gnarly
[07:47:17] baweaver: but otherwise pretty much
[07:47:42] baweaver: Very rarely do you need to implement your own functions like that in the real world, though eventually it's nice to know how they work
[07:48:25] baweaver: reduce and each_with_object just happen to be absurdly overpowered functions capable of reimplementing any of the other Enumerable functions.
[07:48:43] baweaver: Including combinations thereof
[07:49:22] comet23: so why are we going through the pain of all these coding challenges?
[07:49:35] comet23: is it just to get a grasp for logical thinking?
[07:49:37] baweaver: It teaches you to think and consider things
[07:49:51] baweaver: You're not going to come to immediate solutions to things when starting out
[07:50:09] baweaver: Instead take time to write it out, get a feel for how the data flows, and try and find patterns
[07:50:24] baweaver: once you build that recognition you start noticing a lot of problems look awfully similar
[07:50:48] aupadhye: has joined #ruby
[07:59:41] za1b1tsu: has joined #ruby
[08:03:23] nowhere_man: has joined #ruby
[08:03:46] virmagicis: has joined #ruby
[08:11:49] clemens3: has joined #ruby
[08:18:38] aupadhye: has joined #ruby
[08:21:11] akosednar: has joined #ruby
[08:23:37] aupadhye: has joined #ruby
[08:26:52] lunarkitty7: has joined #ruby
[08:33:08] phredus: has joined #ruby
[08:34:01] apparition: has joined #ruby
[08:43:16] nowhere_man: has joined #ruby
[08:43:52] vondruch: has joined #ruby
[08:44:27] faraazahmad_: has joined #ruby
[08:45:58] dinfuehr: has joined #ruby
[08:48:00] rippa: has joined #ruby
[08:48:14] DTZUZO: has joined #ruby
[08:55:54] mikecmpbll: has joined #ruby
[08:58:09] nowhere_man: has joined #ruby
[09:10:27] mikecmpbll: has joined #ruby
[09:11:50] sina: has joined #ruby
[09:21:56] cschneid: has joined #ruby
[09:23:52] aupadhye: has joined #ruby
[09:27:37] jsrn: has joined #ruby
[09:41:26] aupadhye: has joined #ruby
[09:44:19] cd: has joined #ruby
[09:45:56] themsay: has joined #ruby
[09:55:29] kapil____: has joined #ruby
[10:20:18] TomyLobo: has joined #ruby
[10:28:58] cschneid: has joined #ruby
[10:45:22] catphish: has joined #ruby
[10:46:54] queip: has joined #ruby
[10:47:21] catphish: it would be really nice if ruby offered direct access to pipe2() with flags
[10:49:09] sameerynho: has joined #ruby
[10:49:57] tinyhippo: has left #ruby: ("WeeChat 2.3")
[10:53:17] catphish: may need to write a gem for it, though i've never written a C gem before
[10:58:59] themsay: has joined #ruby
[11:19:44] themsay: has joined #ruby
[11:22:10] drale2k_: has joined #ruby
[11:33:28] drale2k_: has joined #ruby
[11:33:29] dminuoso: has joined #ruby
[11:33:35] dminuoso: has left #ruby: ("WeeChat 2.0.1")
[11:40:58] conta: has joined #ruby
[11:43:53] aupadhye: has joined #ruby
[11:44:12] tdy: has joined #ruby
[11:45:43] nowhere_man: has joined #ruby
[11:48:34] aupadhye: has joined #ruby
[11:53:38] jlebrech: has joined #ruby
[12:08:03] marmotini_: has joined #ruby
[12:08:30] vondruch: has joined #ruby
[12:11:16] jlebrech: i want to pack a string into a hexadecimal value, but pack is a method of array and not string
[12:11:18] indocomsoft: has joined #ruby
[12:12:01] al2o3-cr: jlebrech: got an example?
[12:12:29] jlebrech: basically need the reverse of unpack https://ruby-doc.org/core-2.3.0/String.html#method-i-unpack
[12:12:53] jlebrech: or maybe i need to use base62 but i shouldn't need a gem for that
[12:13:04] al2o3-cr: jlebrech: example input expected output?
[12:13:57] donofrio: has joined #ruby
[12:14:29] jlebrech: doesn't seem like the right thing
[12:14:55] jlebrech: only converts string into arrays, should probably use encode and decode instead
[12:15:27] indocomsoft: Hi guys, why does Ruby not has data structures as part of its stdlib? e.g. Python's heapq
[12:16:18] jlebrech: al2o3-cr: i was trying this solution https://stackoverflow.com/questions/17623668/what-does-string-packh-mean
[12:16:22] indocomsoft: Wondering if there's a particular reason
[12:21:10] _whitelogger: has joined #ruby
[12:35:31] nowhere_man: has joined #ruby
[12:36:26] thebigj: has joined #ruby
[12:36:32] thebigj: I am running my blog on Jekyll (https://dpaste.de/y4gG/raw).
[12:36:51] thebigj: Github is trying to give me warning for using 3.3.1. It says to upgrade to whatever version above 3.6.3 source https://github.com/ultimatecoder/Blog/network/alert/Gemfile.lock/jekyll/open
[12:37:01] thebigj: I am following https://jekyllrb.com/docs/upgrading/
[12:37:10] thebigj: Applied all the commands
[12:37:14] thebigj: Still I found it is not upgrading from 3.3.1
[12:37:22] thebigj: Can anyone guide me if I am mistaking anywhere?
[12:39:57] stryek: has joined #ruby
[12:41:29] hays: there is also .bytes and .chars
[12:48:21] catbusters: has joined #ruby
[12:57:27] nowhereman: has joined #ruby
[12:59:35] cschneid: has joined #ruby
[13:05:59] Guest86938: has joined #ruby
[13:10:22] bmurt: has joined #ruby
[13:11:24] Guest86938: has joined #ruby
[13:16:43] indocomsoft: has joined #ruby
[13:17:53] emers2n: has joined #ruby
[13:18:44] vondruch_: has joined #ruby
[13:20:30] emers2n: I'm struggling to format a hash with children to match a JSON request format: https://pastebin.com/raw/pUXGbCNE
[13:20:30] ruby[bot]: emers2n: as I told you already, please use https://gist.github.com
[13:25:06] Guest86938: has joined #ruby
[13:25:29] discopatrick: has joined #ruby
[13:31:59] go|dfish: emers2n: looking at the docs page for that api it says 'Requests are made with a GET request to the specified endpoint with a single parameter, data, which is a base64 and JSON encoded string.'
[13:34:40] go|dfish: emers2n: ok so you're using the lists api which is different however it says 'The arguments should be sent as content type application/json' on https://www.klaviyo.com/docs/api/v2/lists
[13:36:28] go|dfish: emers2n: this means post_form() is incorrect here
[13:41:08] emers2n: go|dfish: Wow, thank you. That's exactly what I was doing wrong, and I've adjusted the code to see successful calls now.
[13:41:43] go|dfish: emers2n: cool :)
[13:43:20] jlebrech: i have a strange issue where i get a template error but it's rendering correctly
[13:48:31] jlebrech: ActionView::Template::Error (undefined method `[]' for nil:NilClass)
[13:48:40] jlebrech: <h1>Project: <%= @context[:context] %></h1>
[13:48:49] jlebrech: but it renders correctly
[13:49:32] Guest86938: has joined #ruby
[13:53:53] agent_white: has joined #ruby
[13:58:06] phaul: has joined #ruby
[14:03:43] aupadhye: has joined #ruby
[14:09:24] mikecmpb_: has joined #ruby
[14:09:37] vondruch: has joined #ruby
[14:17:01] al2o3-cr: catphish: https://gist.github.com/gr33n7007h/a85f0213cfdb9a5a716105c347e9d460
[14:25:57] krawchyk: has joined #ruby
[14:30:20] jcalla: has joined #ruby
[14:31:32] vondruch_: has joined #ruby
[14:35:12] mikecmpbll: has joined #ruby
[14:36:08] NL3limin4t0r: has joined #ruby
[14:43:50] catphish: al2o3-cr: oh that's beautiful, thanks! i had no idea it was that easy to do on the fly
[14:45:18] hutch: has joined #ruby
[14:45:54] GodFather: has joined #ruby
[14:49:47] cschneid: has joined #ruby
[14:51:05] tdy: has joined #ruby
[14:57:05] dminuoso: has joined #ruby
[14:57:12] polishdub: has joined #ruby
[14:57:15] dminuoso: has left #ruby: ("WeeChat 2.0.1")
[14:58:07] d10n-work: has joined #ruby
[14:58:10] Bish: has joined #ruby
[14:58:25] Bish: why is net/http so weird, seperating GET/POST into classes?
[14:58:29] cow[moo]: has joined #ruby
[14:59:58] dkmueller: has joined #ruby
[15:00:29] catphish: well they're different types of request
[15:00:55] catphish: it's sometimes a mild annoyance, but i wouldn't call it weird
[15:01:55] Bish: can't see the benefit of having "Request" Classes
[15:02:23] Bish: what do you do with them except for filling them with data
[15:02:37] Bish: so these things might aswell be parameters
[15:02:50] catphish: you can say the same about any such setup i guess, like the response classes
[15:03:14] vondruch: has joined #ruby
[15:03:20] Bish: well response classes make sense, because they have: return code & content
[15:03:30] Bish: content alone would be useless if you don't know if it's 200
[15:03:35] Bish: that isn't true for requests
[15:04:01] catphish: i don't understand
[15:04:22] Bish: well.. reponse classes contain more information than requests,therefor they're useful
[15:04:35] Bish: request only have a body and head, and they only get written never read
[15:04:45] mspo: a 200 is no different from a 404 from a 999
[15:04:52] catphish: i don't follow that logic, nor do i agree with the facts
[15:05:01] Bish: mspo: weird, last time i checked they were different numbers
[15:05:01] catphish: responses have a return code, the class it just an added niceness, it's redundant in terms of data
[15:05:37] Nicmavr: has joined #ruby
[15:05:54] catphish: requests have no such redundancy, the only place the request method is specified in in the class name
[15:06:10] catphish: but again, it's purely a matter of taste, someone had to make a decision, they did
[15:06:22] mspo: Bish: in http a reponse has way less stuff than a request
[15:06:23] Bish: well everything is
[15:06:26] catphish: it would be perfectly functional either way
[15:06:39] Bish: mspo: how are they any different.. at low level
[15:06:42] Bish: head and body
[15:06:58] Bish: catphish: so is not using types at all
[15:07:02] catphish: "head and body" is a gross oversimplification
[15:07:16] mspo: a request has a verb at least
[15:07:21] mspo: which sets context
[15:07:26] mspo: every response will have the same stuff
[15:07:32] mspo: it's much simpler
[15:07:36] Bish: yeah but good they're not part of the request in ruby
[15:07:40] catphish: anyway, both are fairly simple containers
[15:07:44] Bish: since they have a class for those ^^
[15:07:52] catphish: and it was just a style decision to subclass them
[15:07:55] mspo: http/2 screws it all up, of course :)
[15:08:27] Bish: catphish: guessing the style of fewer people, because i rarely see people use net/http
[15:08:32] Bish: always some httparty something stuff
[15:08:46] TheBrayn: I can really recommend httparty
[15:08:49] TheBrayn: it's a joy to use
[15:08:59] catphish: personally i find the subclassing of http requests to be an annoyance, but not enough to warrant a complaint
[15:08:59] Bish: well i never got the benefit, it does http requests
[15:09:05] Bish: and you add a dependency for it
[15:09:12] Bish: i have only read / fixed code with it, not sure though
[15:09:56] catphish: i always end up with case statements in order to create instances of Net::HTTP::Request
[15:10:32] Bish: like having your own function which then gets a parameter for being get post put patch whatever?
[15:11:42] aufi: has joined #ruby
[15:13:53] Inline: has joined #ruby
[15:14:24] chouhoulis: has joined #ruby
[15:15:29] conta: has joined #ruby
[15:20:03] gnufied: has joined #ruby
[15:22:49] Bish: catphish: so you write your function to get around the great comfort of having multiple requst classes
[15:23:49] catphish: depends on the input data
[15:24:12] catphish: sometimes it's much more convenient being able to instantize a get request directly, other times it's annoying :)
[15:29:17] spacesuitdiver: has joined #ruby
[15:34:52] conta: has joined #ruby
[15:41:47] Rapture: has joined #ruby
[15:44:42] tdy: has joined #ruby
[16:05:43] Renich: has joined #ruby
[16:13:32] Guest86938: has joined #ruby
[16:13:37] RougerRR_: has joined #ruby
[16:15:15] uplime: has joined #ruby
[16:19:41] tdy: has joined #ruby
[16:19:59] davidw_: has joined #ruby
[16:22:16] dviola: has joined #ruby
[16:27:56] Eiam_: has joined #ruby
[16:31:03] tdy: has joined #ruby
[16:31:30] millerti: has joined #ruby
[16:34:45] cthulchu: has joined #ruby
[16:35:25] cthulchu_: has joined #ruby
[16:37:25] maryo: has joined #ruby
[16:40:59] davidw_: has joined #ruby
[16:43:56] \void: has joined #ruby
[16:47:00] conta: has joined #ruby
[16:49:39] galaxie: has joined #ruby
[16:50:58] galaxie: Hi, I finally got annoyed enough to try and solve this problem. Basically I'm using RVM and it has worked for some time but since maybe 6 months ago it doesn't like anything with native extensions and spews garbage about extensions not being built for all these gems and they can't be found.
[16:56:21] galaxie: has joined #ruby
[16:56:56] galaxie: Sorry, bad connection. I tried restoring all gems to pristine condition but that failed too.
[16:57:28] galaxie: I also use LXTerminal and tried integrating it but even bash -l no longer seems to work.
[16:57:53] uplime: what do you mean doesn't work?
[16:58:13] galaxie: As in, same error. No native extensions.
[16:58:19] gnufied: has joined #ruby
[16:59:34] galaxie: Using different versions of Ruby also doesn't help, so it probably is rvm's fault.
[17:07:09] tdy: has joined #ruby
[17:08:04] galaxie: Gems that I install right now with native extensions that seem to install correctly are then not found and ignored.
[17:09:21] uplime: what does `type gem` say?
[17:09:46] galaxie: It's a function linked to rvm.
[17:09:47] reber: has joined #ruby
[17:11:58] conta: has joined #ruby
[17:12:31] phaul: galaxie: paste all error logs you have (full logs please), including the commands you executed.
[17:12:33] conta2: has joined #ruby
[17:13:57] galaxie: Wait a minute, I think I somehow alias'd ruby to something other than rvm's shem or whatever and forgot about it. Wow, that worked.
[17:21:33] bmurt: has joined #ruby
[17:23:42] davidw_: has joined #ruby
[17:27:35] Swyper: has joined #ruby
[17:28:33] cthulchu: has joined #ruby
[17:37:14] film42: has joined #ruby
[17:41:35] orbyt_: has joined #ruby
[17:43:32] film42: I was wondering if it would be worth experimenting with caching of zero-values in ruby. Where [], {}, and "" literals are shared references and only dup'd on mutation.
[17:44:38] film42: The hypothesis being that we often return empty arrays and hashes in rack middlewares.
[17:45:00] davidw_: has joined #ruby
[17:45:27] film42: Might not actually be worth the effort, but wanted to bounce it off #ruby before trying anything.
[17:45:55] r29v: has joined #ruby
[17:48:32] uplime: i thought string literals were already frozen? would they still need to be "cached"?
[17:50:07] sanscoeur: has joined #ruby
[17:50:48] Swyper: has joined #ruby
[17:53:50] conta2: has joined #ruby
[17:54:45] orbyt_: has joined #ruby
[17:55:46] film42: uplime: String literals might be. I'm thinking about array and hash literals as well.
[17:57:21] film42: And not frozen as in "immutable" but cached as in memory is shared until modified. Like the zero-value is an immutable value that is dup'd before mutation.
[17:57:42] hovis: has joined #ruby
[17:57:48] Aqo: has joined #ruby
[18:04:03] KeyJoo: has joined #ruby
[18:05:06] indocomsoft: has joined #ruby
[18:12:07] mikecmpbll: has joined #ruby
[18:12:14] catbusters: I'm trying to create a method inside a class that can only be called from within that class. Here's my code (http://tpcg.io/1REYkr) but I can't get it to work
[18:12:21] catbusters: What am I doing wrong?
[18:13:53] planigan: has joined #ruby
[18:15:04] hutch: has joined #ruby
[18:17:47] phaul: catbusters: you are mixing instance methods and class methods.
[18:19:48] phaul: add is an instance method. call is a class method. calling add from call doesn't work as without explicit receiver it is sent to the class, but the class doesn't have such method
[18:21:44] catbusters: phaul: How can I fix it? I want to be able to do Something.call (without creating a new instance), and the call method needs to call other private methods
[18:22:34] catbusters: In the example above, I removed `private` from the add definition and made it `self.add` which makes it work, but I don't want `Something.add` to be callable
[18:23:15] kapil____: has joined #ruby
[18:26:50] Sou|cutter: has joined #ruby
[18:26:59] phaul: make it private, and make it class method. open the singleton class with class << self .. end syntax, declare a private scope, and define the method (without self)
[18:30:35] catbusters: phaul: You mean like this? https://bpaste.net/show/d06194244e14
[18:31:26] phaul: yes, that should do what you want
[18:34:19] catbusters: phaul: Alright. And what I'm trying to do is create a Rails service object, so does this way of doing it make sense or am I off track?
[18:36:35] sanscoeur: has joined #ruby
[18:38:57] marmotini_: has joined #ruby
[18:40:29] phaul: I'm not sure, I am not a big fan of thsese design patterns in Ruby, I fail to see why just PORM (plain old ruby modules) are not enough to factor code out if the code is separable enough from the rest of the class. But someone else might see things differently
[18:40:47] marmotini: has joined #ruby
[18:42:12] bmurt: has joined #ruby
[18:45:21] FastJack: has joined #ruby
[18:49:03] davidw_: has joined #ruby
[18:55:14] havenwood: Caerus: https://gist.github.com/havenwood/5692bc5667d419b1bbf31d92663c4bb6
[18:55:25] havenwood: oops, bad autocomplete >.>
[18:55:29] havenwood: catbusters: ^
[18:57:03] sanscoeur: has joined #ruby
[18:57:17] havenwood: catbusters: If you aren't instantiating it, use a module instead of a class.
[18:58:16] cnsvc: has joined #ruby
[19:00:18] catbusters: Thanks, I'll try using modules instead. Out of curiosity, is `private_class_method` preferable to `class << self` though?
[19:00:44] catbusters: phaul: PORO is what I was going for
[19:00:44] cnsvc: has joined #ruby
[19:03:04] krawchyk_: has joined #ruby
[19:03:34] RougeR: has joined #ruby
[19:04:33] havenwood: catbusters: They're different things.
[19:04:45] havenwood: catbusters: https://gist.github.com/havenwood/2d4cd1ac0cdcbfd61d77bda0ad81a373
[19:14:09] catbusters: So many ways to do things 😅
[19:14:29] catbusters: Would just defining a method inside a module be enough?
[19:18:34] uplime: are modules able to make use of [public, protected, private] like classes?
[19:19:19] phaul: havenwood: when you said they are different things, I think you misunderstood the question. even though catbusters missed the full code I think it was about private_class_method vs class << self; private def blah .. Those are semantically equivalent right? Just using different syntax to achieve the same
[19:21:21] phaul: in other words a making the instance method of the class' singleton class private is the same as making a class method of the class private.
[19:23:20] phaul: &>> module M; class << self; private def blah; 1; end; end; end; M.blah
[19:23:22] rubydoc: # => private method `blah' called for M:Module (NoMethodError) (https://carc.in/#/r/5y0o)
[19:23:32] phaul: uplime: ^
[19:24:27] themsay: has joined #ruby
[19:24:40] uplime: but M#blah (did i use that right?) is still accessible within M right?
[19:24:53] reber: has joined #ruby
[19:24:54] uplime: guess i could just try it out myself :}
[19:24:56] uplime: thanks phaul
[19:27:06] orbyt_: has joined #ruby
[19:32:29] planigan: has joined #ruby
[19:32:33] orbyt_: has joined #ruby
[19:36:59] hutch: has joined #ruby
[19:37:01] maryo_: has joined #ruby
[19:44:18] orbyt_: has joined #ruby
[19:46:06] RedNifre: has joined #ruby
[19:49:42] ramfjord: has joined #ruby
[19:52:46] SeepingN: has joined #ruby
[19:54:03] havenwood: phaul: Ah, gotcha. You're right, I misunderstood the question.
[19:56:37] perique: has joined #ruby
[20:06:44] Sou|cutter: has joined #ruby
[20:10:21] gix: has joined #ruby
[20:13:31] ur5us: has joined #ruby
[20:21:37] krawchyk: has joined #ruby
[20:26:27] mn3m: has joined #ruby
[20:30:28] RedNifre: has joined #ruby
[20:34:03] davidw_: has joined #ruby
[20:40:21] orbyt_: has joined #ruby
[20:47:21] tdy: has joined #ruby
[20:52:47] conta: has joined #ruby
[20:55:00] sqbell: has joined #ruby
[20:56:11] marmotini: has joined #ruby
[20:58:53] Lytol: has joined #ruby
[21:12:55] conta: has joined #ruby
[21:16:03] davidw_: has joined #ruby
[21:16:09] sanscoeur: has joined #ruby
[21:16:48] RedNifre: has joined #ruby
[21:41:01] Tharbakim: has joined #ruby
[21:43:08] hutch: has joined #ruby
[21:43:13] szulak_: has joined #ruby
[21:57:14] sanscoeur: has joined #ruby
[21:57:47] donofrio: has joined #ruby
[21:58:33] davidw_: has joined #ruby
[22:19:48] davidw_: has joined #ruby
[22:24:50] szulak_: has joined #ruby
[22:31:37] tiff: has joined #ruby
[22:34:30] tdy: has joined #ruby
[22:41:43] postmodern: has joined #ruby
[22:48:22] conta: has joined #ruby
[22:49:20] fuzzface: has joined #ruby
[23:04:47] comet23: has joined #ruby
[23:05:12] comet23: when is a good time to use "and" "or" "not"
[23:14:52] baweaver: Common rule: don't
[23:15:05] baweaver: prefer !, &&, and ||
[23:15:36] baweaver: You're more likely to give yourself headaches with operator precedence by using the english versions comet23
[23:17:03] phaul: &>> a = false or true; a
[23:17:06] rubydoc: # => false (https://carc.in/#/r/5y2q)
[23:19:54] ramfjord: has joined #ruby
[23:21:38] RedNifre: has joined #ruby
[23:24:32] drale2k_: has joined #ruby
[23:35:41] KanKava: has joined #ruby
[23:35:57] KanKava: Hi guys, anyone here uses spree commerce?
[23:38:50] baweaver: kankava: I'd suggest contacting their support channels for questions
[23:38:51] baweaver: They have them listed here: https://spreecommerce.org/
[23:44:46] rkazak: has joined #ruby
[23:45:50] orbyt_: has joined #ruby
[23:45:52] comet23: thank you baweaver
[23:46:21] comet23: so there is absolutely no reason to use the english versions
[23:47:45] baweaver: For where you're currently at in programming, no.
[23:48:51] baweaver: There are exceptions to every rule, but typically you want to play by those rules where possible to avoid confusion.
[23:49:31] baweaver: Much the same with metaprogramming and eval. 99% of the time you don't need them, but every beginner wants to use them at every turn because they have a shiny new tool and it looked fun
[23:49:57] baweaver: More often than not they end up creating a pretty big mess of it when a single-line would have done the same thing if they hadn't been fixating on that.
[23:52:18] comet23: i'm going through app academy's free ruby course
[23:52:32] comet23: they put their whole curriculum out online for free
[23:53:38] comet23: and, or, and not are near-synonyms of &&, ||, and !. The sole difference is that they have lower precedence in the order of operations. For the purposes of this course, we will only be using &&, ||, and ! -- we strongly discourage (at least for now) ever using and, or, and not. Once you've finished the course and are out in the real world, you may find useful applications for these operators, but for now we will not be using
[23:54:09] ansraliant: has joined #ruby
[23:54:11] comet23: i'm sorry i thought it was going to put it in the irccloud pastebin
[23:58:07] Radar: All good. It's only two lines.
[23:58:23] KanKava: @baweaver thanks
[23:58:55] sanscoeur: has joined #ruby
[23:59:43] baweaver: That's a fair assessment by them. There are uses but they're rare and are rarely justifiable