Class: WorkTogether::Student
- Inherits:
-
Object
- Object
- WorkTogether::Student
- Defined in:
- lib/work_together.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#active_track ⇒ Object
Returns the value of attribute active_track.
-
#completion ⇒ Object
Returns the value of attribute completion.
-
#email ⇒ Object
Returns the value of attribute email.
-
#first_name ⇒ Object
Returns the value of attribute first_name.
-
#github_username ⇒ Object
Returns the value of attribute github_username.
-
#last_name ⇒ Object
Returns the value of attribute last_name.
Class Method Summary collapse
- .all ⇒ Object
- .attributes_from_data(data) ⇒ Object
- .build_attributes(headers) ⇒ Object
- .generate_from_data(data) ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ Student
constructor
A new instance of Student.
- #name ⇒ Object
- #progress ⇒ Object
Constructor Details
#initialize ⇒ Student
Returns a new instance of Student.
133 134 135 |
# File 'lib/work_together.rb', line 133 def initialize @@all << self end |
Instance Attribute Details
#active_track ⇒ Object
Returns the value of attribute active_track.
131 132 133 |
# File 'lib/work_together.rb', line 131 def active_track @active_track end |
#completion ⇒ Object
Returns the value of attribute completion.
131 132 133 |
# File 'lib/work_together.rb', line 131 def completion @completion end |
#email ⇒ Object
Returns the value of attribute email.
131 132 133 |
# File 'lib/work_together.rb', line 131 def email @email end |
#first_name ⇒ Object
Returns the value of attribute first_name.
131 132 133 |
# File 'lib/work_together.rb', line 131 def first_name @first_name end |
#github_username ⇒ Object
Returns the value of attribute github_username.
131 132 133 |
# File 'lib/work_together.rb', line 131 def github_username @github_username end |
#last_name ⇒ Object
Returns the value of attribute last_name.
131 132 133 |
# File 'lib/work_together.rb', line 131 def last_name @last_name end |
Class Method Details
.all ⇒ Object
137 138 139 |
# File 'lib/work_together.rb', line 137 def self.all @@all end |
.attributes_from_data(data) ⇒ Object
155 156 157 158 |
# File 'lib/work_together.rb', line 155 def self.attributes_from_data(data) attributes = data.first.to_hash.keys self.build_attributes(attributes) end |
.build_attributes(headers) ⇒ Object
141 142 143 144 145 |
# File 'lib/work_together.rb', line 141 def self.build_attributes(headers) headers.each do |header| attr_accessor header.to_sym end end |
.generate_from_data(data) ⇒ Object
160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/work_together.rb', line 160 def self.generate_from_data(data) attributes_from_data(data) data.each do |student_hash| student_hash.delete_if {|attribute, value| !Student.instance_methods.include?(attribute.to_sym)} self.new.tap do |student| student_hash.each do |attribute, value| student.public_send("#{attribute}=", value) end end end end |
Instance Method Details
#name ⇒ Object
147 148 149 |
# File 'lib/work_together.rb', line 147 def name "#{first_name} #{last_name}" end |
#progress ⇒ Object
151 152 153 |
# File 'lib/work_together.rb', line 151 def progress self.completion end |