Class: Delegation

Inherits:
Array
  • Object
show all
Defined in:
lib/get-your-rep/delegation.rb

Overview

The Delegation class inherits from Array and describes methods that can be called on a Delegation for ease of display and database query.

Instance Method Summary collapse

Methods inherited from Array

#to_del, #to_rep

Instance Method Details

#+(value) ⇒ Object

Overloads the + operator to return a new Delegation instead of an Array.



14
15
16
17
18
19
20
# File 'lib/get-your-rep/delegation.rb', line 14

def +(value)
  if value.is_a?(Delegation)
    super.to_del
  else
    Delegation.new(super)
  end
end

#<<(value) ⇒ Object

Overloads the << operator so the receiving object is not overwritten as an Array, and there are no nested Delegations.



5
6
7
8
9
10
11
# File 'lib/get-your-rep/delegation.rb', line 5

def <<(value)
  if value.is_a?(Delegation) || value.is_a?(Array)
    self.replace(self + value)
  else
    super
  end
end

#business_cardsObject

Maps all rep business cards.



33
34
35
# File 'lib/get-your-rep/delegation.rb', line 33

def business_cards
  self.map { |rep| rep.business_card }
end

#eigthObject

Get the [7] index.



68
69
70
# File 'lib/get-your-rep/delegation.rb', line 68

def eigth
  self[7]
end

#fifthObject

Get the [4] index.



53
54
55
# File 'lib/get-your-rep/delegation.rb', line 53

def fifth
  self[4]
end

#first_namesObject

Collects the first names of every rep in the Delegation.



23
24
25
# File 'lib/get-your-rep/delegation.rb', line 23

def first_names
  self.map { |rep| rep.first_name }
end

#fourthObject

Get the [3] index.



48
49
50
# File 'lib/get-your-rep/delegation.rb', line 48

def fourth
  self[3]
end

#last_namesObject

Collects the last names of every rep in the Delegation.



28
29
30
# File 'lib/get-your-rep/delegation.rb', line 28

def last_names
  self.map { |rep| rep.last_name }
end

#ninthObject

Get the [8] index.



73
74
75
# File 'lib/get-your-rep/delegation.rb', line 73

def ninth
  self[8]
end

#secondObject

Get the [1] index.



38
39
40
# File 'lib/get-your-rep/delegation.rb', line 38

def second
  self[1]
end

#seventhObject

Get the [6] index.



63
64
65
# File 'lib/get-your-rep/delegation.rb', line 63

def seventh
  self[6]
end

#sixthObject

Get the [5] index.



58
59
60
# File 'lib/get-your-rep/delegation.rb', line 58

def sixth
  self[5]
end

#tenthObject

Get the [9] index.



78
79
80
# File 'lib/get-your-rep/delegation.rb', line 78

def tenth
  self[9]
end

#thirdObject

Get the [2] index.



43
44
45
# File 'lib/get-your-rep/delegation.rb', line 43

def third
  self[2]
end