hash as def argument
Is the following possible in any way? I keep running into a odd number list for Hash def thores_hammer(bling) hammer_bling = { bling } end thores_hammer :rubys => 5, :emeralds => 5, :souls => 333 Thanks ahead of time. ...
Is the following possible in any way? I keep running into a odd number list for Hash def thores_hammer(bling) hammer_bling = { bling } end thores_hammer :rubys => 5, :emeralds => 5, :souls => 333 Thanks ahead of time. ...
Alright I have an xml document that looks something like this: <xml> <list> <partner> <name>Some Name</name> <status>active</status> <id>0</id> </partner> <partner> <name>Another Name</name> <status>active</status> <id>1</id> </partner> </list> </xml> I ...
Okay I've read through the plugin comments and the docs as well and I have yet to come up with an answer as to how to do this. Here's my problem I want to use the :info_window_tabs and the :icon option, but I don't know what format to pass my information in. According to the documentation the following code should be correct. Here's my c...
Hi... I m using ruby 1.8.6 on Windows.. I m extending Ruby with C. that is i want to load a DLL into Ruby.. but Ruby fails load my Dll.. i use visual studio.net command Prompt. I integrate my dll namely prov.dll into C program namely pro1.c afterthat i call those c functions through ruby . D:\ruby_extend\pronmake>irb irb(main):00...
I would like to create pdfs with ruby. One special need is embedding a picture into text (or a textblock), which means I need to be able to let the text flow around the image. E.g. the image should be in the rigth upper corner and the text should start left of the image and continue after the image by using the whole width of the page. H...
I have an array: int_array = [11,12] I need to convert it into str_array = ['11','12'] I'm new to this technology ...
I have a terrible Rails test startup time. When running a single functional test that may take 2 seconds to run, the total time from execution to returning to the command line could be up to 10-15 seconds. There are two gems I know are definitely getting in the way. A Facebook and Flickr gem (Facebooker, Flickraw). Facebooker will al...
I am working on a simple ruby assignment and I am getting and internal server error. I am assuming it is in how I am tying my classes together. EDIT: I updated it and now I am just not inserting to the database. The point of issue is where I call "result = @dbh.query(query)" This is my first page: #!/usr/local/bin/ruby require 'cgi...
I have a collection of records in my database that I want to print out to separate tables based on the record date. So I already have the following (in Haml, fyi): %table %tr %th Name %th Type %th Total Hits - for record in @records %tr{ :class => cycle('odd','even') } %td= record.name %td= record.target...
I have user input strings specifying the cost of an event (eg: "$4 for non-members"). I am trying to parse out the upper (and lower) bound of the cost (in the example, upper == lower == 4.00). Suppose that a given string cannot be parsed (maybe it's blank). In this case, I want to be able to store in the database that the maximum cost ...
Hi, I am writing code that will deal with currencies, charges, etc.. I am going to use the BigDecimal class for math & storage. We ran into something weird with it, however. Using this statement: 1876.8 == BigDecimal('1876.8') it returns false. If I run those values through a formatting string "%.13f" I get: "%.20f" % 1876.8 => ...
I am trying to use the googlecharts gem to create some quick charts. Here are the rubyforge and github sites: http://googlecharts.rubyforge.org/ http://github.com/mattetti/googlecharts/tree/master After installing, I keep getting an error saying "no such file to load -- googlecharts" even though when I do a "gem list", the gem is list...
If so, how? When you go to http://rubyonrails.org/download, it says: We recommend Ruby 1.8.7 for use with Rails. Ruby 1.8.6, 1.8.5, 1.8.4 and 1.8.2 are still usable too, but version 1.8.3 is not. ...
I need to write a Ruby method that takes a word, runs it through OS 10.5’s Dictionary.app’s thesaurus function, and returns alternative words. If the Ruby method ends up calling the command-line, that’s fine; I just need to be able to do it programmatically from Ruby. After looking through Ruby OSA, I realize that the Dictionary is acc...
G'day folks. I'm trying to introduce Ruby at work, and a few people are interested. However, I've been asked to present the benefits of Ruby over Python and PHP. I've broken this down into 2 parts: 1) show Python and Ruby's advantages over PHP; 2) show Ruby's advantages over Python. The first is easy. I'll explain things like: Everyt...
Is there a simple way of remapping a hash in ruby the following way: from: {:name => "foo", :value => "bar"} to: {"foo" => "bar"} Preferably in a way that makes it simple to do this operation while iterating over an array of this type of hashes: from: [{:name => "foo", :value => "bar"}, {:name => "foo2", :value => "bar2"}] to:...
I'm new to Treetop and attempting to write a CSS/HSS parser. HSS augments the basic functionality of CSS with nested styles, variables and a kind of mixin functionality. I'm pretty close - the parser can handle CSS - but I fall down when it comes to implementing a style within a style. e.g: #rule #one { #two { color: red; } c...
This is probably a stupidly easy question for a Rails person but is causing me no end of confusion. I downloaded several open source Rails projects but am not able to run them. Usually, are you supposed to do a db:migrate before you try to run a Rails project? I thought they were supposed to just run. ...
I've got two small structural issues that I'm not sure how to handle given my relative newbie-ness with RoR. First issue: In one of my views, I have code that looks like this: <ul style="list-style-type: circle"> <li><%= @apples.size %> apples</li> <li><%= @oranges.size %> oranges</li> <li><%= @bananas.size %> bananas</li> <li>...
I am new to rails and trying to do a little refactoring (putting a partial renderer that lists titles in app/views/shared ) The renderer shows the dates along with the titles. However different users of the renderer use different dates. Part way through refactoring I have title_date = list_titles.created_on For the other user of the r...