I am using Spreadsheet for ruby for creating excel files. Now I want that a excel must be created when it doesnt exist. So I wrote this -:
require 'rubygems'
require 'spreadsheet'
include Spreadsheet
workbook = Spreadsheet.open "data__#{$KEYWORD}.xlsx" rescue Excel.new("data__#{$KEYWORD}.xlsx")
But Always keeps throwing this error -
...
I am using the following regex
html.scan(Regexp.new(/Name:<\/td>(.*?)<\/td>/s))
to match the name [ Burkhart, Peterson & Company ] in this
<td class="generalinfo_left" align="right">Name:</td>
<td class="generalinfo_right">Burkhart, Peterson & Company</td>
...
Hello coders and codetts,
I created an iphone app, and i'm currently in development of a web app to go along, the main goal is to have the iphone collect data and then upload the data to the web app so that the users can view and print the data that was collected, after the data has been uploaded it will be deleted off the iphone.
Now ...
how can i get a list of DateTime objects which match the following criteria:
they are between two instances of DateTime
they fall on a fraction of an hour/min. eg. they are a full quarter of an hour
with active support a possible solution is:
(my_datetime_ob_a.to_i .. my_datetime_ob_b.to_i).each { |timestamp|
puts timestamp if (t...
Hi,
I am wondering, why is an included module's methods mixed in to any subsequent class definitions (as if the class included it in itself)?
module Foo
def bar
print "#{self}\n"
end
end
class Bar
end
begin
Bar.bar
rescue NoMethodError
puts "There is no Bar.bar\n"
end
include Foo
bar
Bar.bar
Bar.new.bar
prints:
There...
I was developing something at the uni, saved to my Dropbox intending to continue at home. This is the message that greeted me:
$ spec graph_spec.rb
/Users/amadan/.rvm/gems/ruby-1.9.2-rc1/gems/PriorityQueue-0.1.2/ext/priority_queue/CPriorityQueue.bundle: [BUG] Segmentation fault
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10...
I am trying to call a helper method in my Sinatra application from irb in order to test its output. I know I can get a console using this tip, and I've tried racksh as well. But if I do a "defined? my_helper" I always get nil. There must be some simple way of getting at those helpers. I have a feeling that this means digging through the ...
I am trying to imple QLineEdit's text which is all capital letters no matter what user types in. I have found several solutions, none of them working in Ruby. In brief I have QLineEdit object searchEdit and this code:
class UpcaseValidator < Qt::Validator
def validate(input,pos)
input.upcase!
Qt::Validator::Acceptable
e...
I have a hex value that I am getting from an XML file and I am trying to use that hex value as the background color for a data table. However, in IE8 it keeps rendering as a string.
When I have used
<%= h(@dhex1[k]) %>
it renders as
<%hex>A8960A<%/hex> with hex tags (note % signs are so browser does not think they are tags)
in...
Here's some background of my problem:
I am on Snow Leopard
I have RVM installed(using a ruby1.9.2-head installation)
I am using rails3
I installed the ym4r using this http://github.com/guilleiguaran/ym4r_gm (and followed the tutorial)
Anyway, I added these to my controller:
@map = GMap.new("map_div")
@map.control_init(:large_map => tr...
I'm sure there is a more idiomatic ruby way to write the code below:
@var = obj['blah'] unless obj['blah'].nil?
I've got a whole load of these to do (see below), and there must be a nicer way!
@num_x = obj['num_x'] unless obj['num_x'].nil?
@num_y = obj['num_y'] unless obj['num_y'].nil?
@num_iterations = obj['num_iterations'] unless o...
Hi,
Is there a release date for Ruby on Rails 3? I've been searching but nothing yet.
...
Learning rails and something smells a little funny.
I have the following form for updating quantities in a shopping cart.
<% form_for(:cart, @cart.items, :url => { :action => "update_cart" }) do |f| %>
<table>
<tr>
<th>Item</th>
<th>Quantity</th>
<th>Price</th>
</tr>
<% for item in @cart.items %>
...
I am reading data from an xml doc and placing it on a web page using rails and REMXL. I use
@description1=XPath.match( xmldoc, "////description" )
to get the info into an array and just loop through in my view. However when using
<%= h(@description1[k]) %>
so it looks like
<description>fuzzy slippers</description>
on the web ...
I'm trying to access an XMLRPC API (for the Magento PHP app) from my Rails application.
I'm using a gem however whenever I try to connect on my local machine (Snow Leopard) I get this error:
no such file to load -- xmlrpc
This is triggered by a line require 'xmlrpc'
Is there a specific Ruby XMLRPC gem I need to install?
Sorry for the...
I've been fighting with a Rails install on my Mac for some time. The error I'm getting (in my development log) says:
Status: 500 Internal Server Error
no such file to load -- mysql
Here's some info:
I can successfully rake db:migrate my application
I've installed the MySQL gem and it appears in the gem list: mysql (2.8.1)
I have Pass...
In a Ruby on Rails application I am trying to use information from fields that are not associated with the model in validation.
Here is part of the model as an example (the whole model has gotten kinda big):
class Scorecard < ActiveRecord::Base
belongs_to :course
belongs_to :user
validate :attributes_consistency
def attribute...
I'm using Datamapper 1.0 with sinatra and sqlite3 as backend.
I have some devices, which have multiple locations, and I usually only want the latest location of a device. The problem is that the generated SQL for the above line will query all locations for the device not just the latest one (and a device can have 10-20k locations). Thi...
In some documentation, Ruby's Win32API has 'L' and 'N' to specify a "number"... and in some documentation, 'L' is "long". Is 'N' deprecated, and isn't 'L' the same as 'I' actually? A "number" is somewhat not so specific.
In
http://rubyforge.org/docman/view.php/85/3463/API.html#M000001
There is no specifying a boolean parameter as '...
Hello,
I'm using Ruby for displaying the contents of powerpoint files in a webpage. I've found solutions using the win32ole but I'm in the linux environment and it doesn't work. I think the application could trigger a openoffice command for conversion.
...