"\none\n two\n  three".scan(/^( *)\w+/).flatten #=> ["", " ", "  "]

Ruby Get rid of useless `flatten`

by Shamaoke, November 06, 2011 02:11, 5 refactorings, tagged with ruby, array, scan

Hi.

I want to get the ar...

E4c1e34040468dff738dda2a3349a36a Talk
# chip away at the bonuses play through amounts
    bet_through_credit_remaining = self.wager
    self.user.bonuses.ranked.each do |bonus|
...

Ruby apply a credit over an orde...

by philrosenstein.myopenid.com, October 21, 2011 15:14, 15 refactorings, tagged with rails, activerecord, array, 2.3.x

example: if the credit is ...

20bffe332e5534f3ea328698ecb0a938 Talk
user_id = xx
users = [....]

...

Ruby move a element of array to top

by Fred Liang, July 06, 2011 07:22, 6 refactorings, tagged with array

There are some elements in ...

48986aabbdbcdeacdbc3a6dc2945a9ff Talk
a = {}
a["test"] = [] if a["test"].nil?
a["test"] << 5

Ruby Fill Array or create it

by Fu86, May 24, 2011 05:07, 3 refactorings, tagged with ruby, hash, array

How can I write this in a c...

Ee0505bbd355292778077fb662c88f13 Talk
input = [9,9,9,9,9,9,9,9,9,9,9,9]
input.uniq == 9

...

Ruby Test if array contains the ...

by astropanic.myopenid.com, May 23, 2011 07:50, 11 refactorings, tagged with speed, array, uniqueness

How I can check all element...

55502f40dc8b7c769880b10874abc9d0 Talk
a = ["a", "b", "c", "d"]
b = [1, 0, 0, 1]

...

Ruby Reject and merge two arrays

by Fu86, May 06, 2011 07:59, 3 refactorings, tagged with ruby, array, merge, reject, collect

I want to collect all the e...

Ee0505bbd355292778077fb662c88f13 Talk
def disease_search(query)
    treatment_results = Array.new
    symptom_results = Array.new
...

Ruby Messy Blocks

by https://www.google.com/accounts/o8/id?id=AItOawncqSogDKAQLilNnxoB32ZKr-9LXu8x3WA, April 06, 2011 02:50, 6 refactorings, tagged with array, rails activerecord, blocks

This is a really ugly metho...

55502f40dc8b7c769880b10874abc9d0 Talk
def disease_search(query)
    treatment_results = Array.new
    symptom_results = Array.new
...

Ruby Messy Blocks

by https://www.google.com/accounts/o8/id?id=AItOawncqSogDKAQLilNnxoB32ZKr-9LXu8x3WA, April 06, 2011 02:50, 4 refactorings, tagged with array, rails activerecord, blocks

This is a really ugly metho...

55502f40dc8b7c769880b10874abc9d0 Talk
# http://www.ruby-forum.com/topic/163649
class Array
...

Ruby Randomized array pairs to s...

by TimK, October 20, 2010 01:43, 2 refactorings, tagged with rails, random, array

The purpose of this code is...

2722012beb9afcad75df5c9f2229fd8c Talk
openid_mapping = {
  :email => ["email", "http://axschema.org/contact/email"], 
  :name => ["fullname", "http://axschema.org/namePerson"]
...

Ruby Hash + Array refactor

by Oriol, August 19, 2010 17:56, 44 refactorings, tagged with ruby, hash, array, openid, sreg, axschema

This actually works but I w...

E4679be8d7d2484f9c0b8c4df71f4d2a Talk
class Array
    
  def count_by(&block)
...

Ruby Array.group_by that counts

by matt, June 26, 2010 23:38, 5 refactorings, tagged with ruby, array, group_by

I want an array method that...

081c31620e9ed8dca87afeeeeb279f68 Talk
def array_to_params(param_name, params)
  unless params.is_a?(Array)
    result = "&#{param_name}[0]=#{params}"
...

Ruby Generate post query for array

by zealer.livejournal.com, June 01, 2010 11:06, 4 refactorings, tagged with POST, array

I need to post some array u...

167c4580d7b338553023cc575ecc2af7 Talk
grouped = [] 
arr = [#<Foo id: 1, status_id: 2, profile_id: 3>,#<Foo id: 2, status_id: 2, profile_id: 3>,#<Foo id: 3, status_id: 1, profile_id: 3>]
arr_copy = arr
...

Ruby group objects in array

by toro04, March 29, 2010 13:44, 4 refactorings, tagged with array

I'm looking for an optimal ...

8abd3736ee784dcd159d3b26b882076e Talk
User has_many Students
Student has_one ReportCard
ReportCard has_many Metrics
...

Ruby Ruby - Chained collect stat...

by umanghc.myopenid.com, October 23, 2009 23:02, 4 refactorings, tagged with ruby, array

Is there a better way to do...

55502f40dc8b7c769880b10874abc9d0 Talk
y_max = 10

arr_data.each do |arr|
...

Ruby 2D array manipulation

by asmega.myopenid.com, September 12, 2009 13:10, 1 refactoring, tagged with ruby, iterate, array, each, if, break, first

an array within array itera...

8969b3dc2e4211b514c08ee9879bb0c4 Talk
tmp = reply.case.users.map(&:email)
tmp.delete(reply.created_by.email)
tmp.join(',')
...

Ruby Remove element from array

by serek.openid.pl, September 03, 2009 12:12, 3 refactorings, tagged with array, remove, remove element from array

I wanted to remove specific...

597821ce12359ab2d95437c8164d5254 Talk
def self.all_leaves
    leaves = []
    Category.roots.each do |category|
...

Ruby array iteration

by RoadHouse, July 23, 2009 23:12, 5 refactorings, tagged with rails, ruby, array

i dont find a better way to...

70089e712ed13abb99bec89bd5bfba77 Talk
class Array
  # does a kind of ZIP compression for integer arrays
  # examples:
...

Ruby compressing an array of int...

by Alec Leitner, April 14, 2009 20:49, 4 refactorings, tagged with ruby, array, compression

I've written a small method...

72820eaf703cd07ba9bc6ecc09e5d81a Talk
# sum an an array's elements
def sum_row(a)
  sum = 0
...

Ruby Conditionally deleting colu...

by srboisvert.myopenid.com, December 18, 2008 00:18, 6 refactorings, tagged with ruby, array, csv

I needed to read in a CSV f...

12d6a2e5971e661ee2bf2994526e848d Talk
array_with_blank_strings.compact.reject(&:blank?)

>> array_with_blank_strings = ["Item 1", "Item 2", " ", "Item 3", nil]
...

Ruby Strip blank Strings and Nil...

by Ivan Vanderbyl, December 07, 2008 21:36, 15 refactorings, tagged with ruby, array, strip, blank

This code will firstly remo...

8991cd8e29cf99d2aebb2301c762e5bd Talk
def browser?(b)
    user_agents = {
      :ff   => /Firefox/,
...

Ruby browser detection and url r...

by seaofclouds, October 16, 2008 18:19, 4 refactorings, tagged with helper, array, browser detect

i have a simple browser det...

F55e8e113669f6ea7d1d99f38907ce54 Talk
def translation_links
    lang = [
      %w[en english us], 
...

Ruby nested array to set of html...

by seaofclouds, October 09, 2008 07:51, 2 refactorings, tagged with ruby, hash, array, translation

i have a simple array that ...

F55e8e113669f6ea7d1d99f38907ce54 Talk
FIELDS = [ 'first', 'last',      'band' ]
DATA   = [['Kurt',  'Cobain',    'Nirvana'],
          ['Jimi',  'Page',      'Led Zeppelin'],
...

Ruby Map fields array and data a...

by charlesroper, September 22, 2008 15:23, 9 refactorings, tagged with hash, array

First posting here. I just ...

93fc84c261cdce2e2f1d64c8e531ecb7 Talk
artists = [1, 2, 3]
    column_1 = artists[0..artists.size/2]
    column_2 = artists[artists.size/2+1..artists.size]

Ruby Split an array into half

by gudata, August 14, 2008 09:49, 11 refactorings, tagged with ruby, array, split

The example works if the ar...

4ee8e20a519f3afdcd03bcf24681dbd8 Talk
times.each do |time|
      events.each do |event|
        if time.strftime("%I:%M %p") == event.datetime.strftime("%I:%M %p")
...

Ruby two for loops cleanup?

by ttdavett.myopenid.com, July 31, 2008 00:11, 7 refactorings, tagged with rails, ruby, hash, array

times is an array of dateti...

F677fa685a2cfe8aff31f161062db3d3 Talk