SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard rctneil's Avatar
    Join Date
    Jun 2005
    Posts
    1,898
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Help with ruby/rails script please

    Hey,

    Here is my code:

    Code Ruby:
    flickr_photo_sizes = []
     
        flickr.photos.getSizes(:photo_id => id).size.each do |flickr_photo_size|
          flickr_photo_sizes << PhotoSize.new({
            :label => flickr_photo_size["label"],
            :source => flickr_photo_size["source"],
            :url => flickr_photo_size["url"]
          })
        end
     
        photo_sizes = Hash.new
     
        photo_sizes = flickr_photo_sizes.each do |size|
          { size['label'].to_sym => { size['url'].to_sym => size['url'], size['source'].to_sym => size['source'] } }
        end
     
        return photo_sizes

    I am printing out the photo_sizes hash but it's not coming out as I expect.

    I am after:

    { :small => { :url => 'this', :source => 'this' }, :medium => { :url => 'this', :source => 'this' }, :large => { :url => 'this', :source => 'this' } }

    I am still very new to ruby and this is just annoying me as I just can't seem to get my head around how to create this hash.

    Any ideas?

    Neil

  2. #2
    SitePoint Wizard rctneil's Avatar
    Join Date
    Jun 2005
    Posts
    1,898
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyone able to help me with this?

  3. #3
    SitePoint Member
    Join Date
    Mar 2013
    Posts
    16
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Could you print flickr_photo_sizes to see the results?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •