ruby-1.8

Implementing auto complete for more than one field in Rails

邮差的信 提交于 2019-12-04 06:18:22
问题 I have an app, which implements a group feature. Each group has n members. Also, each group has a group specific profile pic to it. I have been able to implement auto complete for the group feature keeping in mind the group name alone. I have referred to the following tutorial for the same:- http://railsforum.com/viewtopic.php?id=23188 I am using ruby 1.8.7 and rails 2.0.2 for project specific purpose. I have installed the auto_complete plugin in the appropriate directory. I am on Ubuntu 10

Array#uniq with block equivalent in Ruby 1.8.7

假装没事ソ 提交于 2019-12-04 04:28:21
问题 Array#uniq has this behaviour in Ruby 1.9 c = [ "a:def", "a:xyz", "b:abc", "b:xyz", "c:jkl" ] c.uniq {|s| s[/^\w+/]} #=> [ "a:def", "b:abc", "c:jkl" ] It can take a block and give unique value with respect to what we give. But, this wont work in Ruby 1.8. How can I create this functionality in ruby 1.8? 回答1: Install Marc-André LaFortune's backports gem: https://github.com/marcandre/backports That has the block versions of 1.9.2's Array#uniq and Array#uniq! . Or if you don't want or need the

Spawning an independent thread or process in Ruby

独自空忆成欢 提交于 2019-12-03 12:51:37
I may be approaching this in the wrong direction, so any help would be appreciated. I have a Ruby script which, amongst other things, starts up an executable. I want to start this executable - currently being triggered using system "" - and then continue on with the script. When the script finishes, I want it to exit but leave the executable running. Originally I had the following # Do some work # Start the executable system("executable_to_run.exe") # Continue working But executable_to_run.exe is a blocking executable, and system "" will not exit until the executable finishes running (which I

Implementing auto complete for more than one field in Rails

二次信任 提交于 2019-12-02 07:58:47
I have an app, which implements a group feature. Each group has n members. Also, each group has a group specific profile pic to it. I have been able to implement auto complete for the group feature keeping in mind the group name alone. I have referred to the following tutorial for the same:- http://railsforum.com/viewtopic.php?id=23188 I am using ruby 1.8.7 and rails 2.0.2 for project specific purpose. I have installed the auto_complete plugin in the appropriate directory. I am on Ubuntu 10.04 OS I would like to integrate two more things as part of the current auto complete feature for groups

What's discouraging you from writing ruby 1.9-specific code? [closed]

穿精又带淫゛_ 提交于 2019-12-01 20:56:35
So far, I've been merely using YARV (ruby 1.9) as merely a faster implementation of ruby than ruby 1.8, and ensured that all of my code is backwards-compatible with ruby 1.8.6. What circumstances, if any, are stopping you from writing 1.9-specific code? One reason per answer. neutrino Also, if we're talking about rails, then the problem there is the compatibility of gems/plugins with ruby 1.9. I'm sure everyone who wants to upgrade to 1.9 keeps an eye on isitruby19.com The first release candidate for Ruby 1.9.2 is due end of May and I believe many are waiting for 1.9.2 to hop on the 1.9 train.

What's discouraging you from writing ruby 1.9-specific code? [closed]

旧时模样 提交于 2019-12-01 20:19:21
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . So far, I've been merely using YARV (ruby 1.9) as merely a faster implementation of ruby than ruby 1.8, and ensured that all of my code is backwards-compatible with ruby 1.8.6. What circumstances, if any, are stopping you from writing 1.9-specific code? One reason per answer. 回答1:

How to dynamically create instance methods at runtime?

北战南征 提交于 2019-12-01 17:32:26
[ruby 1.8] Assume I have: dummy "string" do puts "thing" end Now, this is a call to a method which has as input arguments one string and one block. Nice. Now assume I can have a lot of similar calls (different method names, same arguments). Example: otherdummy "string" do puts "thing" end Now because they do the same thing, and they can be hundreds, I don't want create an instance method for each one in the wanted class. I would like rather find a smart way to define the method dynamically at runtime based on a general rule. Is that possible? Which techniques are commonly used? Thanks I'm

How to dynamically create instance methods at runtime?

烂漫一生 提交于 2019-12-01 16:42:59
问题 [ruby 1.8] Assume I have: dummy "string" do puts "thing" end Now, this is a call to a method which has as input arguments one string and one block. Nice. Now assume I can have a lot of similar calls (different method names, same arguments). Example: otherdummy "string" do puts "thing" end Now because they do the same thing, and they can be hundreds, I don't want create an instance method for each one in the wanted class. I would like rather find a smart way to define the method dynamically at

Ruby 1.8: Hash#sort not return hash but array (better way to do this?)

对着背影说爱祢 提交于 2019-12-01 12:36:44
In some scenario of Ruby 1.8. If I have a hash # k is name, v is order foo = { "Jim" => 1, "bar" => 1, "joe" => 2} sorted_by_values = foo.sort {|a, b| a[1] <==> b[1]} #sorted_by_values is an array of array, it's no longer a hash! sorted_by_values.keys.join ',' my workaround is to make method to_hash for Array class. class Array def to_hash(&block) Hash[*self.collect { |k, v| [k, v] }.flatten] end end I can then do the following: sorted_by_values.to_hash.keys.join ',' Is there a better way to do this? Hashes are unordered by definition. There can be no such thing as a sorted Hash. Your best bet

How to count duplicates hash itens in Ruby 1.8.5 ( Sketchup Ruby API )

那年仲夏 提交于 2019-12-01 12:28:11
I need to count the duplicates, they need to be 100% identical to increase my count, but I can not use a nothing out of Ruby 1.8.5, this code will run inside a plugin in google sketchup Google Sketchup Ruby API puts VERSION 1.8.5 puts RUBY_PLATFORM i686-darwin8.10.1 product = 'Glass' x = width y = length z = density product_list = [ { "product" => 1, "x" => 200, "y" => 100, "z" => 18}, { "product" => 1, "x" => 200, "y" => 100, "z" => 18}, { "product" => 1, "x" => 300, "y" => 100, "z" => 18}, { "product" => 2, "x" => 300, "y" => 100, "z" => 18}, { "product" => 2, "x" => 100, "y" => 100, "z" =>