Ruby class inheritance of included gems
class Foo require 'somegem' end class Bar < Foo def to_s puts Somegem.somemethod end end Why is this not working/how can I get something like this to work? ...
class Foo require 'somegem' end class Bar < Foo def to_s puts Somegem.somemethod end end Why is this not working/how can I get something like this to work? ...
Hi, I am having some issues using gsub to replace double slashes. The problem is this: I built a small script to parse YAML files for a directory location, and then to use that to glob the files in that directory. Say this is the directory it finds: C:\Program Files\Adobe\Adobe Flash CS3\en\Configuration\ActionScript 3.0\Classes Thi...
I am not sure if this makes sense but I am thinking if there is a way to suppress the output shown for a command when run using the system method in ruby? I mean it should just output true or false to STDOUT and not the output of the command. What I think is it can just only be done if the command can run silently and not from the system...
Is there any possibility to return multiple values from method? Something like this: def do() return ["a", 10, SomeObject.new] end [a, b, c] = do ...
In Ruby (actually only in Rails, apparently), I know that if I do: some_objects.each(&:foo) It's the same as some_objects.each { |obj| obj.foo } That is -- &foo creates the block { |obj| obj.foo }, turns it into a Proc, and passes it to each. Why does this work? Is it just a Ruby special case, or is there reason why this works as...
I'ld like to send an email with the following setup def registration_confirmation(user) recipients user.username + "<" + user.email + ">" from "Netzwerk Muensterland<[email protected]>" subject "Vielen Dank für Ihre Registrierung" body :user => user content_type "text/html" end The su...
I am using nokogiri to generate svg pictures. I would like to add the correct xml preamble and svg DTD declaration to get something like: <?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg> ... With builder I could use instruct! and declare!...
sudo env ARCHFLAGS="-arch x86_64" gem install do_sqlite3 Building native extensions. This could take a while... ERROR: Error installing do_sqlite3: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb checking for sqlite3.h... yes checking for sqlite3_open() i...
I just wondered whether there is any good reason for or even an advantage in having to invoke Procs using proc.call(args) in Ruby, which makes higher-order function syntax much more verbose and less intuitive. Why not just proc(args)? Why draw a distinction between functions, lambdas and blocks? Basically, it's all the same thing so why...
I've just started working with Ruby, and discovered statement modifiers when RubyMine suggested I change this code: if !VALID_DIRECTIONS.include?(direction) raise ArgumentError, "Invalid direction" end to this: raise ArgumentError, "Invalid direction" if !VALID_DIRECTIONS.include?(direction) I like how it makes the code more suc...
I am rolling my own IP packets for a teach-yourself-Ruby project, and need to compute the IP header checksum (as described in RFC 791 p.14). One of the related questions that popped up when I typed my question here pointed me at RFC 1071, so I'm probably most of the way there, but just to add to Stack Overflow, can anyone (possibly Futur...
Hi there, Currently I am exploring the world of ruby. Playing around in the irb you get nice intellisense for like 5.<tab><tab>. I tried many editors/IDEs (mainly gedit, vim, radrails) with a couple of plugins. I kind of do not like the bloated eclipse-style environment but as far as I fount out it is the only one providing intellisense...
Hi guys, I want to upgrade my rails application 2.0.2 to 2.3.5. After many problem with mysql, I have another big problem with my application. Here is the problem: Processing UserController#profil (for 127.0.0.1 at 2009-12-26 11:47:13) [GET] Rendering template within layouts/admin Rendering user/profil ActionView::TemplateError (unde...
I know that the RoR can do the validation in the models. But I want to confirm the user's password in the views. I means, it show two textfield for user to type password twice to ensure the user type the password correct, but in the database I only store one value. How can I handle it in the RoR? ...
Hi All, I am a starter with ruby, I searched that if someone else has asked similar question but was not able to find any. so I am asking it here. I am trying my hand at modules in ruby. I created a folder Project inside Project folder, created a class One class Project::One include Project::Rest end inside Project folder, cr...
>> a = 5 => 5 >> b = "hello, world!" => "hello, world!" >> b.dup => "hello, world!" >> a.dup TypeError: can't dup Fixnum from (irb):4:in `dup' from (irb):4 I understand that Ruby will make a copy every time you assign an integer to a new variable, but why does Numeric#dup raise an error? Wouldn't this break abstraction, since ...
This is probably considered hacking, but is it possible to programmatically download swfs using something like Ruby? Not decompiling them, just downloading them so I can view them without having to go to the site with a billion advertisements. ...
Why is the power! method in Ruby's Fixnum class named with an exclamation mark? By convention, methods that have a name ending in an ! are potentially dangerous (for example, they may modify the instance in some way). I can appreciate the difference between gsub and gsub! in String, but what's up with power!? It doesn't seem to modify...
What should I do before upgrading to the latest version of Ruby? any tips? Update sorry for my unclear question. my condition: I've upgraded my Ruby from 1.8.7 to 1.9.1p243. It makes me can not use all installed gems. so, what should I do before upgrading Ruby? uninstall all my installed gems? I was looking in other SO posts in here...
I've just completed a new open source gem for the Silentale API and I'm facing a strange issue. In terminal I'm getting an error saying that it can't load the gem however it continues to start the server loading it without any issues. no such file to load -- silentale-on-rails /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem...