#ruby - 23 March 2018
« Back 1 day Forward 1 day »
[01:53:18] pabloh: Any body knows if is possible to delegate a method preserving the original arity?
[01:57:53] pabloh: what I would like is to have "MClass.method(:original).paramters == MClass.method(:delegated).paramters"
[02:10:04] pabloh: I basically want to copy a instance method to the class so it becomes a class method as well
[04:23:23] b100s: hi2all; is it possible to have one endpoint for one net interface and another for second net interface in one ruby sinatra app ?
[04:28:16] havenwood: b100s: That sounds quite possible, but I'm not quite sure I know what you're meaning.
[05:11:07] havenwood: newguy8822: in irb you can shell out if you want with backticks: `gem install hola`
[05:11:29] havenwood: or in pry you can use the `gem-install` command to both install then require the gem: gem-install hola
[05:11:34] ruby[bot]: Pry, the better IRB, provides easy object inspection `ls`, `history`, viewing docs `?`, viewing source `$`, syntax highlighting and other features (see `help` for more). Put `binding.pry` in your source code for easy debugging. Install Pry (https://pryrepl.org/): gem install pry pry-doc
[05:21:25] newguy8822: i installed nokogiri but cant require it, does anyone know what went wrong? C:/Ruby25-x64/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require': cannot load such file -- nokogiri (LoadError)
[05:29:28] newguy8822: is this a windows bug? 'make' is not recognized as an internal or external command, operable program or batch file.
[10:05:20] schneider: I have this small script, and whenever I run "./foo.rb crud create" the documentation shows all the commands omiting "crud" in the first place
[10:06:05] schneider: instead of showing "./foo.rb crud create file # Creating a file" it shows me "./foo.rb create file # Creating a file"
[12:46:52] z64: you can get pretty creative with it. it can also cause some nasty bugs if you're not careful. no problem
[13:09:01] ineb: besides its use in metaprogramming and maybe unit testing, send makes the concept of oop programming clear where messages are 'send' to objects
[13:09:49] ineb: but you are right that a member function should be called directly whenever possible
[13:47:53] mrtAkdeniz: guys, I'm so noob on ruby, and just working for little things where bash is not enough...
[13:50:29] mrtAkdeniz: https://gist.github.com/iquad/72072ebbe6986202d9b598ff68357505 here is my problem.. I wrote that `parser.rb` to find and replace on a file, and it works, but only 1 problem
[13:50:57] mrtAkdeniz: on heredoc, it is escaping `\` character... I don't want it to do... My expected result is `expected.php` but real result is `result.php`
[13:59:51] phaul: interesting. Try enclosing the heredoc marker in single quotes after the <<- (but not at the end).
[14:05:58] mrtAkdeniz: phaul, interesting.. I remember that, I did try that... I mean, 'DOCNAME' part, but was no luck..
[17:01:45] cagomez: If I have module Foo::A, Foo::A::Factory, Foo::A::Util. Why can I just reference Util in Foo::A::Factory as Util?
[17:05:25] cagomez: Since Util is a "sibling" (same directory) as Factory, does that make it available?
[17:06:23] cagomez: I reference Util in Factory but am not sure when it actually becomes available. I can see both Factory and Util under `Foo::A.constants`
[17:08:48] havenwood: cagomez: There's no traversing the namespaces. Just top level or current level.
[17:16:17] cagomez: havenwood: If I have classes like Foo::A::Components::Wheel, Foo::A::Components::Door, is there a way to make these constants available in Foo::A::Factory ? using Components.const_get() sometimes finds classes in my app/models folder
[17:16:47] ruby[bot]: apeiros: # => /tmp/execpad-51b07dd1a6af/source-51b07dd1a6af:7: syntax error, unexpected end-of-input, expecting ke ...check link for more (https://eval.in/977667)
[17:16:57] cagomez: I'm trying to get my Factory to find the constants defined in Foo::A first and not have to reach the "top level"
[17:17:01] apeiros: >> module A; X = 1; module B; module C; def self.x; X; end; end; end; end; A::B::C.x
[17:17:43] apeiros: >> module A; module B; module C; def self.nesting; Module.nesting; end; end; end; end; A::B::C.nesting
[17:18:14] apeiros: >> module A; module B; module C; end; end; end; module A::B::C; def self.nesting; Module.nesting; end; end; A::B::C.nesting
[17:19:23] apeiros: dminuoso last time said I was incorrect about Module.nesting but I forgot what his amendment was :-/
[17:29:23] dminuoso: apeiros: Oh I just said that nesting in detail is modified in a stack machine at runtime, so it's not a syntax thing.
[17:45:21] cagomez: I have a Module Recipient, Class Factory. Is it bad form to have Module Recipient with Module Factory nested inside, and then have an anonymous class inside Factory?
[17:46:41] havenwood: cagomez: See if you can make the whole thing simpler. Try the simplest thing that can possibly work and see how that feels.
[17:50:49] cagomez: my issue is that Users::Getters.const_get(:GoodUser) will find the class in my app/models folder. Will placing the "getters" in the same root directory as factory.rb cause those constants to be defined when Factory is ran?
[21:40:19] cagomez: I have classes in a module that map to classes in my app/models. Eg GoodUser model -> MyModule::GoodUserUtil. I have a MyModule::Factory. Is there a way of "selecting" the correct class in my module?
[21:42:16] apeiros: cagomez: I don't understand what you're looking for. can you make a minimal example which would work except for the "selecting" part?
[21:45:48] cagomez: apeiros: https://hastebin.com/afuneruhew.rb . so I have a factory that uses a case statement, based on the class of my User, to initialize a Util class
[21:46:29] OrangeFlash81: Hello all, does anybody know if there's a gem which I can use to interact with TWAIN scanners?
[21:47:59] cagomez: apeiros: Instead of this case statement, I'd like another approach. I'm trying to avoid adding a method to each of my models, like `def do_something; GoodUserUtil.call; end` on my GoodUser model
[21:49:44] apeiros: cagomez: you still seem to leave away a lot of information (maybe you consider it as self-evident?)
[22:04:19] ramfjord: cagomez: I'm also not sure exactly what you're trying to do, but if you just want the names to match up (a la rails) you can consider calling #to_s on your class/module, modifying the string, and getting a constant back out of it with Module#const-get (https://ruby-doc.org/core-2.1.0/Module.html#method-i-const_get)
[22:04:57] ramfjord: this is assuming that you can get the correct class programatically from the name of the module, or vice versa
[22:06:07] ruby[bot]: cagomez: 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
[23:51:43] panzi: where is the documentation of File.read? It is not here: http://ruby-doc.org/core-2.2.2/File.html where else can it be!?