Re: Extract number (float) from string

2012-12-08 Thread Robert Klemme
On Tue, Dec 4, 2012 at 9:01 PM, botp wrote: > On Wed, Dec 5, 2012 at 2:31 AM, Alexander G. wrote: >> >> how to extract exact number from string: >> $5.99 /LB >> need to get 5.99 as float number > > > see ri String#slice > > eg, > >>"$5.99 /LB"[/[\d.]+/].to_f > => 5.99 That's a quite lazy match w

Re: Mentoring Request

2012-12-08 Thread Robert Klemme
On Fri, Dec 7, 2012 at 9:30 PM, karthik kottapalli wrote: > Let me know if any of you are open to mentoring. I would need 20 minutes per > month of your time. > > A quick high level review of the side-project I am working on, advice on my > coding style and concrete, actionable items I can work o

Re: Rows and columns in a text file.

2012-12-08 Thread Robert Klemme
On Fri, Dec 7, 2012 at 4:24 AM, 7stud -- wrote: > Joao Silva wrote in post #1088123: > results = [] > rows = 9 > columns = 8 Hey, that's cheating. :-) The algorithm must determine these from the input. Two more solutions puts "-- 1 --" lines = [] max = 0 File.foreach "t" do |line| line.cho

Re: Array#concat Enumerator

2012-12-08 Thread Robert Klemme
On Thu, Dec 6, 2012 at 10:43 AM, Intransition wrote: > Shouldn't this work? > > [].concat("abc".chars) > > Seems extraneous that one would have to do: > > [].concat("abc".chars.to_a) Then do irb(main):013:0> ["foo"].push(*"abc".chars) => ["foo", "a", "b", "c"] Cheers robert -- remember.gu

Re: if n belongs to set a and m belongs to set b repeat some steps, How?

2012-12-08 Thread Robert Klemme
On Sat, Dec 8, 2012 at 6:05 AM, zubair a. wrote: > We can do so in java and similar languages like: > > for (int i=0, int j=3; i<=2 && j<=5;i++,j++){ > do some repetive task until the condition becomes false... > } > > how to keep these two conditions based on two different sets(suppose two > ar

Re: Parsing json which require username and password

2012-12-08 Thread Robert Klemme
On Sat, Dec 8, 2012 at 9:47 AM, Ferdous ara wrote: > Hi > I want Fetch a web page which has json output, but the problem is, that > page has username and password, so i am using like this > > #!/usr/bin/ruby > require 'rubygems' > require 'json' > > > > current=`curl -fs -basic -u "username:pass