#ruby - 28 June 2016
« Back 1 day Forward 1 day »
[01:41:57] adam12: I've used it here. Didn't know that you ran it (see it elsewhere too obv, since you stalk me in other channels).
[01:42:41] ruby[bot]: jhass: I'm terribly sorry, I could not evaluate your code because of an error: Net::OpenTimeout:execution expired
[01:45:03] ruby[bot]: jhass: I'm terribly sorry, I could not evaluate your code because of an error: Net::OpenTimeout:execution expired
[03:34:23] hastur: hey, i just `gem install pg` yet the stack trace sayd "cannot load such file: pg". what gives?
[03:49:00] hastur: at some point, you don't really have to know the idiosyncracies of every tool you use in order to merely use those tools
[03:50:48] Arcaire: Systemwide ruby is just pacman -S ruby on my desktop, or whatever downloaded and installed in /usr myself
[03:52:35] Arcaire: i'd rather have all my projects on one ruby version with semi-variable gem versions than totally variable everythings because you did 'rvm install' on a different date.
[03:53:00] Arcaire: ofc this doesn't work in "production" because people haven't worked out that Docker is a meta-meme yet and is actually okay.
[03:54:10] hastur: i have to applaud the way you turned what i said into what you said because that's a gorgeous use of meta
[04:05:40] Gnosis: You guys are either young or very passionate about memes and how a meme may become okay again.
[07:15:57] dminuoso: soulisson: Blocks are one of the very few things in Ruby that are actually not objects. But in a sense you are right.
[07:16:41] dminuoso: They do get implicitly passed, and you get test for their presence using block_given?
[07:19:24] dminuoso: soulisson: But you have no direct way to interact with the block other than either a) calling yield or b) bind it to a proc.
[07:24:12] dminuoso: soulisson: Interestingly any proc object has a block attached to it - but it is that proc that is an actual Ruby object. That is also why binding a block to a proc is relatively cheap, because you only need to create a really small proc object, and then the block pointer gets assigned to it.
[07:25:45] dminuoso: soulisson: They are not in fact. They also belong to that small group of things that are not objects.
[07:27:17] dminuoso: soulisson: The third and I think last bit is variables, they also are not objects.
[07:40:44] User458764: I try to convert a String to an Array, my array string is "[1, 2, 3]" and String.try_convert "[1, 2, 3]" returns me another String but not an Array, why?
[11:03:42] shortCircuit__: I have a module Abc which has a method foo and I also have a class Def which include Abc and also has a method foo .. now c = Def.new .. c.foo calls the class's foo ... how do I call the module's foo .... like a delegate or something
[11:19:02] Hanmac: shortCircuit__: from where do you want to call the Abc#foo ? from inside the Def#foo or from the object c ?
[11:20:40] Hanmac: from the Def#foo, just use "super", from the object you might need to alias the method to something lese like abc_foo
[13:22:34] Bish: hi folkies, how would you parse strings like [<user>][:<password>@hostname[:<port>]
[13:22:58] Bish: i could use URI but i would've to prepend a dummyschema first, which i think is dirty
[14:19:44] jhass: shevy: is that so? What's a regex for finding the character at N/2 a string for arbitrary length N?
[14:39:08] l4v2: what class are most of the assertion methods in? because I don’t see Test::Unit::Assertion
[14:39:56] ljarvis: because those are here: http://ruby-doc.org/stdlib-2.0.0/libdoc/minitest/rdoc/MiniTest/Assertions.html
[14:42:16] l4v2: I’m still in very on in learning Ruby and Rails, so I am not sure about that, but that was Rubies Docs. But then again, Rails might inheret a lot from Ruby
[14:47:16] l4v2: So if I am inhereting from this class class PasswordResetsTest < ActionDispatch::IntegrationTest Then how do I have access to a mehtod I don’t see listed in it like: assert_template Where do these methods live?
[14:53:07] l4v2: ljarvis, I am going up the dependancy tree, and got to Minitest::Test and I don’t see it
[14:54:34] ljarvis: because as i just said, you should type it into the rails docs i just linked you: http://api.rubyonrails.org/classes/ActionController/TemplateAssertions.html#method-i-assert_template
[14:54:36] l4v2: More than anything, I am just trying to learn how to find things when I need them, or just see what options a class has
[14:55:02] ljarvis: you would generally search the api docs for the class or method name, and then look
[14:55:33] ljarvis: e.g. if you want the docs for ActiveRecord::Base, you can just type it into api.rubyonrails.org
[15:02:07] l4v2: THis is the unfriendliest room. I’m asking a general question to improve my skills, should I talk about cars?
[15:04:59] jhass: shevy: http://rubular.com/r/cInPEcoPy7 is what I tried, it works for the first and second, but how do I get c for the third and fourth and d for the fifth?
[15:25:04] mark_66: has left #ruby: ("PART #RubyOnRails :PART #elixir-lang :PART #crystal-lang :PONG :sinisalo.freenode.net")
[16:01:40] workmad3: wrkrcoop: you need to include the module into a class, and then that method will be available as an instance method of the class
[16:27:24] elomatreb: Good evening. Does anyone in here have some experience with writing a custom Redcarpet renderer class?
[16:31:06] smathy: wrkrcoop, or you can use the `extend self` trick - not sure how kosher that's considered /cc workmad3
[16:39:12] havenwood: Wildfyr: Looking for something that already exists to look at or to do yourself?
[16:45:00] havenwood: Wildfyr: Exercism has some good challenges and feedback to hone your answer: http://exercism.io/languages/ruby
[16:48:43] havenwood: class Module; alias module_funkitron module_function endalias module_funkitron
[16:50:31] havenwood: Wildfyr: Even if you don't want to use exercism they have some good project ideas. But I'd suggest giving it a try since you can get some good feedback. Show us your project here too!
[17:10:31] havenwood: baweaver: When you want the module method but also a private method by the same name when you include the module.
[17:13:39] havenwood: Like fileutils, etc in the stdlib - you might want to call the self.method-style directly on the module, but alternatively you might want to include the module, but have the included method be private. I'm having not-enough-coffee explaining difficulty. :P
[17:27:17] funrep: im just not sure what the "?" means, because i cant find a variable with tatt exact name, only without the ? in the libraries docs
[17:32:20] baweaver: any? asks if any objects in the enumerable are true. We're asking the objects in the block if they're even. 2 is, so any? is true.
[17:34:32] baweaver: `map!` transforms the array. `map` simply returns a new array without modifying the original.
[17:36:10] baweaver: Consider also reading through Eloquent Ruby, as it tends to cover a lot of this information in more detail than I can hope to on IRC.
[17:42:50] l4v2: Ok so how am I supposed to know that methods from MiniTest in Ruby are available in Rails class ActionDispatch::IntegrationTest
[17:45:04] smathy: l4v2, it's probably not a parent class, probably just mixed in. The Rails API isn't really very formally specified, mostly people know because they learnt from a tutorial, generator, or some article/post from the web.
[17:48:25] havenwood: l4v2: Just an aside, but it's Minitest now (the MiniTest lost the capital T in Minitest 5): https://github.com/seattlerb/minitest/blob/master/History.rdoc#500--2013-05-10
[17:49:20] l4v2: Oh well then someone needs to tell Ruby docs that lol http://ruby-doc.org/stdlib-2.0.0/libdoc/minitest/rdoc/MiniTest.html#top
[17:54:36] funrep: what kind of "function/method" is this? https://www.libgosu.org/rdoc/Gosu.html#button_down%3F-class_method it doesnt wrap its arguments in paranthesses when called in this context: "if Gosu::button_down? Gosu::KbLeft or Gosu::button_down? Gosu::GpLeft then"
[17:55:33] shevy: was there a way from within a ruby script to move the cursor to the very left side? e. g if someone would do print "hi", to erase the hi and "jump" as to the cursor position before hi was printed
[17:56:00] havenwood: l4v2: Ruby 2.0 is past end-of-life and Ruby 2.1 is not receiving bug fixes since it's in maintenance mode. If you can switch to Ruby 2.2.5 or Ruby 2.3.1 it'd be best!
[17:56:43] l4v2: That was where my Google search brought me, I didn’t even catch that. Yeah I am using 2.3.1
[18:04:13] wrkrcoop: im writing a integration spec and when i write get "person/v1/lookup/" :ids => “1,2,3” the ids dont get passed in
[18:04:26] wrkrcoop: i took this syntax from the post example https://www.relishapp.com/rspec/rspec-rails/docs/request-specs/request-spec
[18:05:03] ruby[bot]: Please join #RubyOnRails for Rails questions. You need to be identified with NickServ, see /msg NickServ HELP
[18:06:43] l4v2: havenwood the require ‘test_helper’ file may be where those assertions are in the ActionDispatch::IntegrationTest class. But here’s my question, I don’t have this gem in my Gemfile, so can I require gems just for certain files? Is that what is going on there?
[18:10:25] havenwood: l4v2: If you're prefixing `bundle exec` to your command or rubygems_bundler is doing it for you then you're limited to exactly the gems and versions thereof in your Gemfile.lock file
[19:17:08] aldodelgado: Is it possible to create a model scope that returns a set of results and then from those results have a condition to only return the strings from a column?
[19:17:26] aldodelgado: Thats the query I can do in the console. However I’d like to make it a scope
[19:19:59] ruby[bot]: aldodelgado: Please join #RubyOnRails for Rails questions. You need to be identified with NickServ, see /msg NickServ HELP
[19:43:18] Gasher: I'm trying to do some file reading and writing, but I don't see proper things about reading the file in the docs
[19:43:46] Gasher: for example, I know there is the method .gets to a file ('file1.gets') that reads something, but it's not in the File class in the docs
[19:48:24] havenwood: Gasher: You can use `File.read` but you'll find the docs in IO: http://ruby-doc.org/core/IO.html#method-c-read
[20:02:17] shevy: well File has for instance chmod stuff, which IO does not have http://ruby-doc.org/core-2.2.0/File.html
[20:03:27] shevy: I compared the ruby readline docs, and the longer explanation here http://bogojoker.com/readline/
[20:25:10] drbrain: … IO wraps things like write(2) and read(2), File wraps file-specific functionality as mentioned (chmod)
[21:11:53] drbrain: isberg: Process.spawn and system let you do arbitrary IO redirection for the child process
[21:12:16] alexandernst: How would I convert "while not a and not b" to use "unless"? "unless a and not b"? "unless a and b"?
[21:12:35] drbrain: if you don't need to capture output, `system "whatever", "command", "here", out: IO::NULL, err: IO::NULL; p $?`
[21:13:24] isberg: drbrain Kernel#system only takes a string. It's nice to pass arguments separately to avoid escaping
[21:13:54] ljarvis: alexandernst: the while is check "not a and not b", so the opposite is "yes a or yes b", aka "a or b"
[21:15:34] alexandernst: I feel completely stupid googling "how to do until in ruby" having 15 years or C/C++ experience on my back...
[21:15:48] drbrain: isberg: to keep it from freezing you'll need to read the data in like pontiki said
[21:16:01] alexandernst: ljarvis: I'd avoid using until at all, but the linter I'm forced to use at work complains about "while not" ...
[21:16:04] ljarvis: alexandernst: if you're having difficulty writing it, it'll be difficult to read/maintain
[21:17:03] ljarvis: alexandernst: you can't add a rule to avoid it blowing up on that? it's ridiculous that it's making your code worse. That's against the whole point of a linter
[21:17:43] drbrain: isberg: without reading the data out of the pipe eventually its buffer fills up and the child process will stall on write
[21:17:53] wrkrcoop: i have two arrays a = [1,2,3,4,5] and b = [5,6,7,8,9] is there a method that allows me to detect duplicates?
[21:27:19] wrkrcoop: i have 2 arrays a = [1,2,3,4] and b =  is there a method that will return [1,2,3]
[21:30:24] baweaver: wrkrcoop: You might want to read up on the Array documentation some more: http://ruby-doc.org/core-2.3.1/Array.html
[22:41:29] bonhoeffer: is there an equivalent to * notation in python -- the ability to turn a list into arguments
[22:45:56] ruby[bot]: havenwood: # => can't modify frozen String (RuntimeError) ...check link for more (https://eval.in/597255)
[22:55:26] ruby[bot]: drbrain: # => can't modify frozen String (RuntimeError) ...check link for more (https://eval.in/597258)
[22:56:06] drbrain: for +-"foo" first the string is dup'd and frozen, then the frozen string is dup'd, then "bar" is appended
[22:56:46] drbrain: for -+"foo" first the string is returned (because it isn't frozen), then the string is dup'd and frozen, then you get the RuntimeError because you can't append to a frozen "foo"