Class: ProjectPurpose
- Inherits:
-
Object
- Object
- ProjectPurpose
- Defined in:
- app/models/project_purpose.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#label ⇒ Object
Returns the value of attribute label.
Class Method Summary collapse
- .all ⇒ Object
-
.label_for(id) ⇒ Object
Returns the label for a given purpose id.
Instance Method Summary collapse
-
#initialize(id, label) ⇒ ProjectPurpose
constructor
A new instance of ProjectPurpose.
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
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'app/models/project_purpose.rb', line 3 def id @id end |
#label ⇒ Object
Returns the value of attribute label.
3 4 5 |
# File 'app/models/project_purpose.rb', line 3 def label @label end |
Class Method Details
.all ⇒ Object
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 |