ruby

Is there any Windows API that can "normalize" or "maximize" a window?

I was using Ruby's Win32API to MoveWindow to move a window and resize it. But if the window is minimized, it won't show. SetWindowPos works too, and has a flag to hide or show the window, but it is to only make a window visible or invisible, not about minimizing or normalizing. I also tried SetForegroundWindow and SetActiveWindow and ...

What is a good way to "sandbox" Ruby 1.8.6 and 1.9.1?

Nowadays I hope to have 2 Ruby versions on the same machine, because some gems are good for 1.8.6 only and at the same time, 1.9.1 is fast and it is to try out with Rails 2.3. Is there a good way to sandbox the two versions? I installed 1.9.1 onto C:\ruby and 1.8.6 onto C:\ruby1.8.6, and change inside of C:\ruby1.8.6\bin copy ruby.exe...

Win32's FindWindow() can find a particular window with the exact title, but what about "try.bat - Notepad"?

Win32's FindWindow() can find a window having the title of "Untitled - Notepad", but what if I just want to find a Notepad window but don't know whether it is "try.bat - Notepad" or some other file name on the title bar? It seems that if the title is passed in a NULL value, then any window will be returned, but only one window is return...

Ruby: Paperclip, S3, and Deep-cloning

What I have is a Theme model, which contains many Assets. Assets are using Paperclip and storing their file content in my Amazon AWS-S3 system. I'm also using deep_clone because my customers have the ability to copy built in Themes and then modify them to their hearts content. All the deep_clone stuff is working great, but when I deep...

How to Write hyperlinks using spreadsheet gem in Ruby?

The spreadsheet gem isnt documented properly, so I cant understand how can I write hyperlinks using spreadsheet gem. Can anyone tell me? ...

How to Read whole file in ruby?

Is there any pre build function by which we can read the whole file without using any loop? So far i have only come across the ones which output line one by one or character one by one. ...

How to nuke all Ruby Gems from the system and start over

What's the easiest way to start over with Ruby Gems? I have Ruby 1.8.7 (OSX, ports) installed and I have also installed rails and some other random stuff a while back. Now the gems system seems to be totally dysfunctional and I can't upgrade rails. So is there a way to just nuke the gems so I can reinstall all this stuff with current ver...

RDebug Turn off Key Echo

I'm currently using GDB to debug a C Extension for Rails 3. Everything works perfectly except for RDebug contexts, where both GDB and RDebug echo my key input. How can I turn off the key echo for RDebug? I don't believe I can solve this through GDB, as that would require constantly switching the echo on and off. ...

Trying to get Warehouseapp to work on Windows

Hi, I have downloaded and am trying to run warehouse app http://warehouseapp.com (a subversion front end). I have got xampp installed on my Windows Home Server and I have it working on port 80. I have set up the ruby on rails server using this guide grapethinking.com/getting-rails-to-work-on-a-windows-machine-running-xampp I copy the w...

What is the equivalent of preg_quote()?

In PHP you need to use preg_quote() to escape all the characters in a string that have a particular meaning in a regular expression, to allow (in example) preg_match() to search for those special characters. What is the equivalent in Ruby of the following code? // The content of this variable is obtained from user input, in example. $s...

Ruby plugin architecture

I have to develop a plugin based software in ruby. What's the best architeture tu use? I am thinking about plugin like this, each in a separate .rb file: class MyPlugin < Plugin def info infos end def run # run end end How i can write a plugin manager to call these plugins? ...

How can I use PHP 5.3 Closures like We use Blocks in Ruby

How can I use PHP 5.3 Closures like We use Blocks in Ruby. I never used 'for' Loop in Ruby due to using Blocks with 'each' 'find_all' 'inject' Methods. How can I use PHP 5.3 Closures like Ruby Blocks and say bye-bye to 'for' Loops :) Like Between { and } is a Closure(or Block or Anonymous Function) fruit = %w[apple banana orange] frui...

How can I set a constant with namespace in the initializers?

Help! in my rails controllers, there is a 'Admin' namespace. (My the structure of the controllers dir is like this : app/controllers: home_controller.rb ... admin/posts_controller.rb admin/pages_controller.rb The 'Admin' will automatically become a Module constant (I know it from the console: 'puts Admin => Module'); And...

How can I know whether a class is inherited from another one? Some methods like is_a?

Simple example: class A end class B < A end Then, how can I judge whether class B is inherited from class A? Is there a method somehow like is_a? or maybe called is_child_of?? I can't find one. ...

Could not locate Gemfile

I'm certainly no Ruby developer but I have an application on my server using Ruby, Gems, and Bundler. I am trying to install another Ruby on under a different user account but on the same VPS. When I go to run bundle install I get the following error: Could not locate Gemfile I could remove the contents of the ./bundle director...

What is different between Ruby in standard OS X distribution, RVM and MacPorts?

I have asked a question on SuperUser about updating Ruby version in Google SketchUp. It seems that there is something different between Ruby shipped with the standard OS X distribution, and Ruby installed by RVM or MacPorts. I get the following error message when I try to use RVM's or MacPorts' Ruby 1.9.1 Exception Type: EXC_BREAKPOINT...

Curb curb-fu gem installation problem

Hello I've installed the Curb and Curb-fu gem and libcurl on my Ubuntu box. If I go into irb and run the following irb(main):001:0> require 'rubygems' => true irb(main):002:0> require 'curb' => true irb(main):003:0> require 'json' => true irb(main):004:0> require 'curb-fu' => true irb(main):005:0> So it seems that I have access to ...

Ruby: How to get a local's and/or a instance varialble's by them self?

From example: local_var = "Thanks!" @instance_var = "Thank you ,too" Then how can I get the local_var and instance_var part by them self. I mean weather there is a method maybe called get_self_name to get the name of himself: local_var.get_self_name # => 'local_var' @instance_var.get_self_name # => '@instance_var' or => 'instance_var...

is there an option on Ruby like mysql_insert_id() for PHP??

Hi Guys!! I would like to know if can be an option on Ruby like mysql_insert_id() for PHP. Thanks a lot ...

Ruby Split By Part of a Regex

I have to write an argument parser, it is passed in as a string ala {a, b, c} delimiter is comma with a space after it, but it can be escaped with a pipe "|" before it. So I was thinking of writing a regex like /[^\|], / to split by, and then removing all the escape characters afterwards. But when using this it will split by the characte...