Sha256: df7ad914de93e5b372f277a82a74c68f796389ad5b5d239bc19d673030b5817c
Contents?: true
Size: 1.62 KB
Versions: 10
Compression:
Stored size: 1.62 KB
Contents
module GetYourRep # The Delegation class inherits from Array and describes methods that can be called on a Delegation for ease of display and database query. class Delegation < Array # Overloads the << operator so the receiving object is not overwritten as an Array, and there are no nested Delegations. def <<(value) if value.is_a?(Delegation) || value.is_a?(Array) self.replace(self + value) else super end end # Overloads the + operator to return a new Delegation instead of an Array. def +(value) super.to_del end # Overloads #reverse to return a new Delegation instead of an Array. def reverse self.replace(super) end # Collects the first names of every rep in the Delegation. def first_names self.map { |rep| rep.first_name } end # Collects the last names of every rep in the Delegation. def last_names self.map { |rep| rep.last_name } end # Maps all rep business cards. def business_cards self.map { |rep| rep.business_card } end # Get the [1] index. def second self[1] end # Get the [2] index. def third self[2] end # Get the [3] index. def fourth self[3] end # Get the [4] index. def fifth self[4] end # Get the [5] index. def sixth self[5] end # Get the [6] index. def seventh self[6] end # Get the [7] index. def eigth self[7] end # Get the [8] index. def ninth self[8] end # Get the [9] index. def tenth self[9] end end end
Version data entries
10 entries across 10 versions & 1 rubygems