class EntertainmentOperations
Public Class Methods
getHighestRated(hashArray)
click to toggle source
# File lib/entertainment_operations.rb, line 25 def self.getHighestRated(hashArray) hashArray = sortByRating(hashArray) return hashArray.first end
getLowestRated(hashArray)
click to toggle source
# File lib/entertainment_operations.rb, line 30 def self.getLowestRated(hashArray) hashArray = sortByRating(hashArray) return hashArray.last end
sortByRating(hashArray)
click to toggle source
# File lib/entertainment_operations.rb, line 2 def self.sortByRating(hashArray) # sorts in ascending order of rating: hashArray.sort_by! do |item| if item[:rating].nil? return -1 else item[:rating] end end return hashArray.reverse end
sortByTitle(hashArray)
click to toggle source
# File lib/entertainment_operations.rb, line 14 def self.sortByTitle(hashArray) # sorts by name alphabetically hashArray.sort_by do |item| if item[:name].nil? 'zzzzzzzzzzzzzzzzzz' else item[:name].downcase end end end