Sha256: 2110e30ad4bc6f371ca95b1cb8c92be60e8ce8f7f9be0713ae661997d98d3fb4
Contents?: true
Size: 621 Bytes
Versions: 5
Compression:
Stored size: 621 Bytes
Contents
module Waiter class Menu class ItemList < Array def initialize(ary = [], sort_options = {}) super(ary) sort(sort_options) end def include?(other) return map(&:name).include?(other) if other.is_a? Symbol super end def [](index) return detect{ |item| item.name == index } if index.is_a? Symbol super end def names map(&:name) end def sort(options = {}) sort_by!(&options[:sort].to_sym) if options.fetch(:sort, false) reverse! if options.fetch(:reverse, false) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems