Re: Array#concat Enumerator

2012-12-09 Thread Robert Klemme
On Sun, Dec 9, 2012 at 7:24 PM, Marc Heiler wrote: > Who uses .push when .<< is so much nicer. That lies in the eye of the beholder, doesn't it? A typical use case is when you want to append several values which are not stored in an Enumerable. Using << can become quite lengthy because " << " t

Help me improve Hash#rekey

2012-12-09 Thread Intransition
The note `TODO: Improve Hash#rekey code!!!` has been in my docs for too long. I could use other's insights and thought others might enjoy the challenge. So here's the code: require 'facets/na' class Hash # Rekey a hash: # # rekey() # rekey(from_key => to_key, ...) #

Re: Array#concat Enumerator

2012-12-09 Thread Intransition
> > > irb(main):013:0> ["foo"].push(*"abc".chars) > => ["foo", "a", "b", "c"] > > A bit beside the point though. I was wondering if #concat should be able to handle an Enumerator. But I didn't know push could take more than one argument, so that's something learned today. Thanks! -- You r

Re: [ANN] Chitin 1.0.3

2012-12-09 Thread Intransition
> > > How did you go about it exactly? How does this differ from say, running `pry` and `include FileUtils` at toplevel? -- You received this message because you are subscribed to the Google Groups ruby-talk-google group. To post to this group, send email to [email protected].

Re: Searching a hash by value

2012-12-09 Thread Robert Klemme
On Sun, Dec 9, 2012 at 2:21 PM, Ferdous ara wrote: > may be i need to design my logic in a different way > let me explain > > basically in that hash table (out put of JSON) > > as key => value > > > > i got like this > [ > { > "notes_expanded" : "check_maintanance_mode", > "host_comments" :

Re: Searching a hash by value

2012-12-09 Thread Robert Klemme
On Sun, Dec 9, 2012 at 1:35 PM, Ferdous ara wrote: > but will this work : #value["host_display_name"] ?? > I will try in a bit .. No. For lookup by value you can use Hash#rassoc: irb(main):003:0> h={"foo" => "bar"} => {"foo"=>"bar"} irb(main):004:0> h.rassoc "bar" => ["foo", "bar"] irb(main):0

Re: Parsing json which require username and password

2012-12-09 Thread Robert Klemme
On Sat, Dec 8, 2012 at 11:33 AM, Ferdous ara wrote: > HI thanks > but i found the solution > > i had to use , because its using the Basica Auth mode in apache, the > bellow command fix the issue > > > request.basic_auth 'xxx','xxx' i'd also look into mechanize gem if you do need to to more intera