thatsmesofia thatsmesofia - 3 months ago 23
Ruby Question

Rails method to iterate through hash of photos and return value according to criteria

I want to create a method (ruby on rails) to iterate through a hash of photos I am pulling from an API (url, name, date created etc) and return only the dates that are in the correct params the user inputs. Inside of the hash you have "created_time" as one of the keys, and that is what I am interested in. Any suggestions?

def pull_time do |picture|
if picture.created_time >= @start_date && picture.created_time <= @end_date
return @pictures


Use between: { |picture| picture.created_time.between?(@start_date, @end_date) }