Greetings,
My question is why do I have 3 separate gem paths. My 'gem environment' command displays the following:
GEM PATHS
- /Library/Ruby/Gems/1.8
- /Users/adam/.gem/ruby1.8 --This one makes sense to me
- /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
Why the two separate "system" paths?
Thanks...
Hello,
If I have a value 'Dog' and an array ['Cat', 'Dog', 'Bird'] How do I check this w/o looping through. Is there a simple way of checking if the value exists, nothing more.
...
Hi,
I'm creating an application in RubyCocoa and I have this code:
fileContents = OSX::NSAttributedString.alloc.initWithData_options_documentAttributes_error_(data, null, null, outError)
It gives me this error:
2009-12-31 19:42:54.317 Ruby Text[3791:a0f] MyDocument#readFromData_ofType_error_: OSX::OCMessageSendException: Can't get O...
I've written a method to turn a hash (nested if necessary) of values into a chain that can be used with eval to dynamically return values from an object.
E.g. passed a hash like { :user => { :club => :title }}, it will return "user.club.title", which I can then eval. (The point of this is to write a method for views that will allow me ...
Hi,
I'm new to Ruby and am trying to pass a sort_by lambda to a format method, like this:
sort_by_methods = [ lambda {|l, r| compare_by_gender_then_last_name(l, r)},
lambda {|l, r| compare_by_something_else(l, r)},
lambda {|l, r| compare_by_another(l, r)}]
formatted_output = ""
sort_by_methods...
I have the following rspec code:
require 'spec_helper'
require 'mocha'
require 'rr'
describe ProjectsController, "creating a new project" do
integrate_views
it "should redirect to project with a notice on successful save" do
Project.any_instance.stubs(:valid?).returns(true)
#mock.instance_of(Project).valid? {true}
Proj...
I'm currently working on a new app based around an existing database, making use of DataMapper for the data access. However, its conventions when dealing with foreign keys are not what the database uses.
Example:
class Invoice
include DataMapper::Resource
storage_names[:default] = 'invoices'
property :id, Serial
# ... more pr...
I am using the authlogic gem with Ruby on Rails, and I have been using the following to obtain the id of the user that is currently logged in:
current_user = UserSession.find
id = current_user && current_user.record.id
I'm not understanding how current_user && current_user.record.id returns the current user id. I would think this woul...
Say there are 3 circles: red, blue, black.
I only want the black circle to remain. How can I remove the red and blue circles?
...
I have a ruby script array when each element needs processing :
threads = []
elemets.each do |element|
threads.push(Thread.new{process(element)}}
end
threads.each { |aThread| aThread.join }
how ever due to resource limitations, the script works in an optimal way if no more the four elements are processed at a time.
no I know ...
I am trying to follow this tutorial and I get the following error which turns up no google results and I'm still too inexperienced to know how to fix it. Any suggestions?
ERROR: While executing gem ... (TypeError)
wrong argument type Symbol (expected Proc)
I am not even sure what gem bundle does exactly so I am not sure where to ...
PHP has a lot of trouble with multibyte strings (non-ASCII characters). The entire language was built assuming that each character is a byte. To solve this they invented the mb_strings functions which you can use instead of the standard functions (which work fine).
strlen($str);
mb_strlen($str); // correct
However, this is really a pa...
It seems to me that the YAML library that ships with ruby 1.9 is encoding-deaf.
What this means is that when generating YAML, it'll take any string of bytes, and escape any byte sequence that doesn't output clean ASCII. That's lame, but acceptable.
My problem is the other way around. When loading content from said YAML dump.
In the ex...
Ruby has constants and global variables for stdio.
Namely, the consts STDIN, STDOUT, STDERR, and their variable counterparts, $stdin, $stdout, $stderr.
I understand the difference between a constant and a variable. I know the constants are immutably set to the file descriptors at the moment the script was exec'd.
I also understand tha...
Hi,
The only US weather data that is available free for commercial use is the US National Weather Service. I'd like to use it. Is there a Ruby/Rails library for accessing it?
Perl would also be helpful. They provide a Perl example. I'd use it as a guide for writing the Ruby version.
...
I'm playing around with Rubygame. I installed it with the Mac Pack, and now I have the rsdl executable. rsdl game.rb works fine, but when I chmod +x the rb file, add the shebang to rsdl (tried direct path and /usr/bin/env rsdl) and try to execute it (./game.rb), it starts to flicker between the Terminal and rsdl which is trying to open, ...
I want to create ruby application (not rails). This is a console app which will need to persist some data. I'm using pstore as the database. I want to deploy this application as a gem.
My question is: where does my data live?
Currently I've created a data directory as a sibling to the bin directory in a standard gem layout. I would th...
I am building a small IDE with fxruby.
The default caret of FXTextField is a little bit ugly (a big tall thin 'I'), I hope I could change the caret style but can't find any help after several hours of googling.
Any hint?
...
Hi I have a strange situation here:
# Is there a semantic difference between these 2 in ruby?
class MyClass < ClassThatExtendsActiveRecordBase
...
# code snippet A:
def image_width(size); self.image.width(size); end
# vs code snippet B
def image_width(size)
self.image.width(size)
end
end
I have a situation where code...
Hello,
our homework is to write a ruby script who calculate a subset of wordlist depending on the expression.
regular binary operations are
&& And operator
|| Or operator
++ Concatenate operator
! Negation operator
A valid call would be like
./eval.rb wordlist && a c
or
./eval.rb wordlist && || a b c
First call means generate a n...