Tagged Questions
0
votes
2answers
39 views
how to convert array output to normal string in ruby on rails application
I am implementing tag functionality and an article may have one to many tags. I am able to get tag values from db in this format
["social network", "professional"]
I want output in this format
...
1
vote
0answers
24 views
Find and replace a time string in Ruby for TaskPaper Logging
I'm using Brett Terpstra's Ruby script to find and log completed TaskPaper items as found here: https://gist.github.com/ttscoff/1913007
This script searches lines for lines that have tags that look ...
-1
votes
1answer
53 views
Pattern Matching with Ruby
Im looking to match two strings and return a score, I don't care about order, just the percentage of character matches.. I was looking at the 'string_score' gem but it cares about order.. as can seen ...
-1
votes
2answers
51 views
Codecademy “converting between symbols and strings” ruby lesson
These are Codecademy's instructions:
We have an array of strings we'd like to later use as hash keys, but we'd rather they be symbols. Create a new array, symbols. Use .each to iterate over the ...
0
votes
1answer
35 views
.map ruby statement not displaying as I expect
I have a has many join table and displaying data based on that table. The data has been mapped and I have confirmed the classes of the variable as being a string.
However in the actual table it ...
0
votes
2answers
24 views
Adding a string into time member and saving to database
I have a duration column in my database table in which I want to insert a timespan, like 02:00 or 19:20 (hours and minutes), the column type is time. The user sees a form with two dropdown lists, one ...
0
votes
0answers
46 views
Error comparing strings?
When I run the following code where str is of type string:
def self.split(str)
array = Array.new
for i in 0..str.length-1
if str[i].casecmp('a') == 0 || str[i].casecmp(':') == 0
...
1
vote
6answers
42 views
Interpolate a string every 3 characters starting from the end
I'm trying to interpolate a comma into a string for every three digits. Interpolation has to be done from the end of the string. So, the input is:
"12345678"
And the output should be:
"12,345,678"
...
0
votes
2answers
18 views
List of substitutions in external file
I need to pass a string against an external file that contains a list of substitutions to perform at every occurrence.
The substitution file will look like this (I'm open to suggestions on the ...
2
votes
4answers
62 views
How do I split string into array of multiple words?
I have a string that I'm using .split(' ') on to split up the string into an array of words. Can I use a similar method to split the string into an array of 2 words instead?
Returns an array where ...
0
votes
0answers
21 views
Ruby using libxml to order strings
I would like to use the libxml and I have the following problem.
XML Code
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<CteObject id="c0">
<!--Created by CTE XL ...
3
votes
5answers
55 views
Ruby modify a piece of a string
Totally new to Ruby. This is a simple homework assignment. The secret_code function needs to take in input string and perform the following actions:
In the first block of letters before a space, ...
3
votes
3answers
55 views
String concatenation in Rails 3
I'm wondering why this is so: Ruby concatenates two strings if there is a space between the plus and the next string. But if there is no space, does it apply some unary operator?
...
1
vote
1answer
49 views
can't edit internationalization string in my rails project
I'm new enough to Ruby, and I've inherited a big project; up to now I've been coping just fine changing text on buttons/ forms/ text boxes by doing the following:
If I want to change the text on an ...
5
votes
2answers
77 views
Generate random string based on Regex?
I wonder if there is a way to generate random string from a regex like:
/[a-z0-9]{5}/.to_s
#=> "dsar3"
I found randexp (https://github.com/benburkert/randexp) but it seems to not work with a ...