Re: Select "columns" from multidimensional array?

2013-02-21 Thread Robert Klemme
On Thu, Feb 21, 2013 at 1:40 PM, Joel Pearson wrote: > I thought I could avoid the issue of splitting the data into multiple > outputs by creating copies of the class, but apparently I was wrong: > > irb(main):002:0> m = RubyExcel.new.load [['a','b']] > => columns: 2, rows: 1, values: 2 > > irb(ma

Re: Select "columns" from multidimensional array?

2013-02-19 Thread Robert Klemme
On Tue, Feb 19, 2013 at 10:51 AM, Joel Pearson wrote: > Using the filter method on my previous attempt would return a copy of > the object containing only the required data. I was hoping for something > similar with this so I can split into multiple sections using filter > logic but still keep the

Re: Select "columns" from multidimensional array?

2013-02-19 Thread Robert Klemme
On Tue, Feb 19, 2013 at 12:47 AM, Joel Pearson wrote: > After more face-to-keyboard action, I came up with a working filter > system. it modifies self at the moment rather than returning a copy, > which is something I'll have to look intosince I'm not sure I want that > to be the default behaviou

Re: Select "columns" from multidimensional array?

2013-02-18 Thread Robert Klemme
On Mon, Feb 18, 2013 at 6:23 PM, Joel Pearson wrote: > That Regexp to proc idea looks good. I could use proc form for a > positive match and a normal block for the negative. I'll see if I can > get something like this working when I write filter method for > RubyExcel. > > Using the new class I ca

Re: Select "columns" from multidimensional array?

2013-02-18 Thread Robert Klemme
On Mon, Feb 18, 2013 at 4:50 PM, Joel Pearson wrote: > I went with "filter" with an optional true/false regex switch because it > seemed like the simplest way to use it, and closest to my own experience > in using Excel's filters. > Passing the symbol feels less intuitive, and yielding to a block

Re: Select "columns" from multidimensional array?

2013-02-18 Thread Robert Klemme
On Mon, Feb 18, 2013 at 2:43 PM, Joel Pearson wrote: > I do use switches occasionally, here's one example where I think it's > justified (from my older Excel_Sheet > def filter( header, regex, switch=true ) > fail ArgumentError, "#{regex} is not valid Regexp" unless regex.class > == Regexp >

Re: Select "columns" from multidimensional array?

2013-02-18 Thread Robert Klemme
p {|x| "<#{x.inspect}>"} => ["<\"f\">", "<\"o\">", "<\"o\">", "<\" \">", "<\"b\">", "<\"a\">", "<\"r\">&quo

Re: Select "columns" from multidimensional array?

2013-02-17 Thread Robert Klemme
On Sun, Feb 17, 2013 at 9:14 PM, Joel Pearson wrote: > I've attached my attempt at converting your code to suit mine (hope you > don't mind the plagarism :p ) No, it's not a doctoral thesis. :-) (allusion to German politics) > I have a list of some of my plans to add functionality at the top, a

Re: Select "columns" from multidimensional array?

2013-02-15 Thread Robert Klemme
On Fri, Feb 15, 2013 at 3:55 PM, Joel Pearson wrote: > Hah, I wrote that head exploding comment first and then managed to work > out what it did afterwards. Still took a few minutes of smashing my head > into the desk to make room for the new thought though ;¬) LOL > Using a Hash sounds like a g

Re: Select "columns" from multidimensional array?

2013-02-15 Thread Robert Klemme
On Thu, Feb 14, 2013 at 11:50 PM, Joel Pearson wrote: > Interesting Matrix build. It's giving me a bit of a headache just trying > to figure out the links involved. > > So MatrixPart defines the methods and the "parent" matrix (held as an > instance variable); and row and column both use these met

Re: Select "columns" from multidimensional array?

2013-02-13 Thread Robert Klemme
On Tue, Feb 12, 2013 at 10:49 PM, Robert Klemme wrote: > On Tue, Feb 12, 2013 at 9:26 PM, Joel Pearson wrote: >> Thanks for the advice and examples, I'll see whether I can understand >> how the classes and methods work with each other there and set about >> experimenting with them. > > I didn't p

Re: Select "columns" from multidimensional array?

2013-02-12 Thread Robert Klemme
On Tue, Feb 12, 2013 at 9:26 PM, Joel Pearson wrote: > Thanks for the advice and examples, I'll see whether I can understand > how the classes and methods work with each other there and set about > experimenting with them. I didn't put commenting in the gist. If there's anything unclear feel fre

Re: Select "columns" from multidimensional array?

2013-02-12 Thread Robert Klemme
On Tue, Feb 12, 2013 at 2:06 PM, Joel Pearson wrote: > Robert Klemme wrote in post #1096452: >> anybody can override header values or complete >> rows / columns violating your class's idea of internal state. > > This class only gets added into scripts, and I'm the only one who knows > Ruby where I

Re: Select "columns" from multidimensional array?

2013-02-12 Thread Robert Klemme
On Tue, Feb 12, 2013 at 1:19 PM, Joel Pearson wrote: > I've decided to inherit from array after all, since all I want to do > with this is extend support for multidimensional arrays, but without > overwriting any of Array's methods. I usually do not engage in predictions since I don't have a crys

Re: Select "columns" from multidimensional array?

2013-02-04 Thread Robert Klemme
On Sun, Feb 3, 2013 at 11:43 PM, Joel Pearson wrote: > I decided to try and build on the Array class as I don't really > understand Matrices yet. I've added a few handy methods. The hidden Bang > stuff is justified, I think, as this class is intended to mimic Excel's > layout. > class Excel_Sheet

Re: Select "columns" from multidimensional array?

2013-02-03 Thread Robert Klemme
On Sat, Feb 2, 2013 at 10:04 PM, Joel Pearson wrote: > Robert Klemme wrote in post #1094583: >> write your own - it is the most >> reasonable thing to have a specific class for handling this instead of >> writing functions which work with a nested Array structure. > > It's only just dawned on me j

Re: Select "columns" from multidimensional array?

2013-01-31 Thread Robert Klemme
On Thu, Jan 31, 2013 at 3:14 PM, Joel Pearson wrote: > Thanks robert You're welcome! > My current approach is > HTML Table -> Nokogiri Nodeset -> Multidimensional Array -> Excel / TSV > > A Matrix looks like a useful way of grabbing the values I need when I > hav

Re: Select "columns" from multidimensional array?

2013-01-31 Thread Robert Klemme
On Thu, Jan 31, 2013 at 11:34 AM, Joel Pearson wrote: > Praise Jesus! > > My initial output was the desired one, but the "transpose" method is > what I was missing. Thanks :) I'd really start by creating a class for this - or use Matrix from the standard library. irb(main):008:0> m = Matrix[[1,2

Re: Multidimensional Array

2012-12-04 Thread Alan Forrester
On Wed, Nov 28, 2012 at 2:15 PM, John M. wrote: > Hi , > > Currently I am using Ruby and a beginner > > I have the following multidimensional Array: > > [[value1, value1_other1 ,value1_other2], [value2, > value2_other1,value2_other2], [value3, value3_other1,value3_other2]]