Class: ProjectPurpose

Inherits:
Object
  • Object
show all
Defined in:
app/models/project_purpose.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, label) ⇒ ProjectPurpose

Returns a new instance of ProjectPurpose.



5
6
7
8
# File 'app/models/project_purpose.rb', line 5

def initialize(id, label)
  @id = id
  @label = label
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



3
4
5
# File 'app/models/project_purpose.rb', line 3

def id
  @id
end

#labelObject

Returns the value of attribute label.



3
4
5
# File 'app/models/project_purpose.rb', line 3

def label
  @label
end

Class Method Details

.allObject



10
11
12
13
14
15
# File 'app/models/project_purpose.rb', line 10

def self.all
  research = ProjectPurpose.new("research", "Research")
  admin = ProjectPurpose.new("administrative", "Administrative")
  teaching = ProjectPurpose.new("teaching", "Teaching")
  [research, admin, teaching]
end

.label_for(id) ⇒ Object

Returns the label for a given purpose id



18
19
20
21
22
23
# File 'app/models/project_purpose.rb', line 18

def self.label_for(id)
  all.each do |purpose|
    return purpose.label if purpose.id == id
  end
  id
end