jeudi 12 janvier 2017

How to get each value from hash of array?

I have a hash of array with key, values in ruby which I want to pass each value with key. I want to extract content using my hash. My code is :

    def get_content
       GetPageContent.new(@pdf.id, session[:selected_pages][@document.id.to_s])
    end

in session[:selected_pages] i got like this

 {"15"=>["001"], "24"=>["001","005"]}

In this first value is pdf id and second value is page number of that pdf.

I want this :

GetPageContent.new(@pdf.id, session[:selected_pages][@document.id.to_s])

I want to pass all values like this:

GetPageContent.new(15, 001)
GetPageContent.new(24, 001)
GetPageContent.new(24, 005)

Please help me out. How to map each key values from hash of array.

Aucun commentaire:

Enregistrer un commentaire