I want to allow people using my program to build up what amounts to several if conditions, which they will select from drop down lists.
First drop down : object
Second drop down : attribute
Third drop down : sign
Fourth drop down : amount
So the user's selection might look something like this;
person_a
age
>
18
Is it possible to bu...
I'm trying to find the first and second half of a string of numbers with ruby ignoring the central digit if the length is odd
i.e
input = "102"
first_half = "1"
second_half = "2"
using this code
i = gets
first_half=i[0..(i.length / 2 - 1).floor]
second_half = i[i.length -first_half.length)..i.length - 1]
print "#{first_half}\n#{second...
I'm trying to get a Textile Editor Helper on my Rails site. I installed the latest version from git, installed it and now trying to get things running. I put the code:
<p>
<%= f.label :message %><br />
<%= f.textile_editor :message -%>
</p>
but Rails return an error, pointing I don't have a proper method:
undefined method `tex...
I'm working on a free, simple, hopefully multi-platform hotkey launcher tool, written in Ruby.
Right now I'm struggling with some threading issues of the Windows implementation.
The rough proof of concept code shown below already works reliably in my day-to-day use:
HotkeyProcessor#process_keypress (footnote 1) gets called by the C cod...
I'm looking for a good library to output iCalendar formatted files.
Good time zone support, or (better yet) UTC-only dates is a requirement.
...
I'm taking a first look at Monk and the Ohm/Redis APIs and I have a simple question. Is it possible to update attributes on model objects using Ohm/Redis?
class Event < Ohm::Model
attribute :name
index :name
end
Event.create(:name => "A mistake made here...")
@event = Event.find(:id, 25)
@event.name = "I want to edit my mistake.....
I'm building a simple Ruby on Rails plugin and I'm considering using the Set class. I don't see the Set class used all too often in other people's code.
Is there a reason why people choose to use (subclasses of) Array rather than a set? Would using a set introduce dependecy problems for some people?
...
Hello, I'm trying to install the mysql gem under Windows 7 x64. Ruby -v is ruby 1.8.6 (2009-03-31 patchlevel 368) [i386-mingw32] and gem is 1.3.4. So the problem is, when I try to "gem install mysql", I get the following error:
D:\ruby\lib\ruby\gems\1.8\gems\mysql-2.7>gem install mysql
Building native extensions. This could take a whil...
I'm trying to do the exercises in "The Little Schemer" using Ruby. I'd like to know the equivalent method of atom? in Scheme for Ruby.
atom? is a method that returns true if the argument passed in is an atom and returns false otherwise.
From what I understand, an atom can be a string of characters or a number. It can't be a list.
...
I wanted to validate 'numericality' of a string (its not an attribute in an active-record model). I just need it to be a valid base 10, positive integer string. I am doing this:
class String
def numeric?
# Check if every character is a digit
!!self.match(/\A[0-9]+\Z/)
end
end
class String
def numeric?
# Check...
Hi I'm trying to extract the parameters from a class definition.
class locale.company.app.LoginData(username:String, password:String)
I have extracted the package name and class name, but the parameters are causing me some trouble.
I used Rubular to construct the following regex:
http://www.rubular.com/regexes/9597
According to Ru...
Quick background: I have a string which contains references to other pages. The pages are linked to using the format: "#12". A hash followed by the ID of the page.
Say I have the following string:
str = 'This string links to the pages #12 and #125'
I already know the IDs of the pages that need linking:
page_ids = str.scan(/#(\d*)/)....
Hi, I have an array of strings:
["username", "String", "password", "String"]
And I want to convert this array to a list of Field objects:
class Field
attr_reader :name, :type
def initialize(name, type)
@name = name
@type = type
end
end
So I need to map "username", "String" => Field.new("username", "Strin...
I've found a few posts alluding to the fact that you can validate XHTML against its DTD using the nokogiri gem. Whilst I've managed to use it to parse XHTML successfully (looking for 'a' tags etc.), I'm struggling to validate documents.
For me, this:
doc = Nokogiri::XML(Net::HTTP.get(URI.parse("http://www.w3.org")))
puts doc.validate
...
I'm trying to growl from Ruby/Appscript, based on this sample Applescript code:
tell application "GrowlHelperApp"
set the enabledNotificationsList to {"Mail Notification"}
register as application "MailWidgetGrowlHelper" all notifications enabledNotificationsList default notifications enabledNotificationsList icon of application ...
I'm trying to output an xml file blog.xml as yaml, for dropping into vision.app, a tool for designing shopify e-commerce sites locally.
Shopify's yaml looks like this:
- id: 2
handle: bigcheese-blog
title: Bigcheese blog
url: /blogs/bigcheese-blog
articles:
- id: 1
title: 'One thing you probably did not know yet...'
...
As much as I love Netbeans for Ruby programming the traditional white background and drab color coding leave me with Textmate envy.
Is there any solution to this in the absence of buying a Mac?
...
Noob question:
Consider the following C# code:
public IEnumerable<xpto> CalculatedList {
get { foreach(var item in privateList.OfType<xpto>()) yield return item; }
}
What would be the correspondent code in Ruby? The thing is that I want the return object of a class method to behave just like an Enumerable, so I can call include?, s...
I have a calendar_date_select in a view that shows a table listing all the information on a certain phone. I want to add a To: and From: date range that a user can select and update the table in the view. The structure is like this:
Usage Controller
Detail action in the usage controller that shows the call history from a certain phone.
...
I want to start contributing to Rails, fixing patches, submitting my own code etc, and the Rails guide states that the tests MUST run. However, they're currently not and I'm not quite sure what to do.
I'm running Mac OS X, Ruby 1.8 and I have all the needed gems installed - what can I do?
...