Class: Curricula::Course
- Inherits:
-
Object
- Object
- Curricula::Course
- Defined in:
- lib/curricula.rb
Instance Attribute Summary collapse
-
#cruciality ⇒ Object
Returns the value of attribute cruciality.
-
#hours ⇒ Object
readonly
Returns the value of attribute hours.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#prereqs ⇒ Object
Returns the value of attribute prereqs.
Instance Method Summary collapse
- #graph_edges ⇒ Object
-
#initialize(name, hours) ⇒ Course
constructor
A new instance of Course.
Constructor Details
#initialize(name, hours) ⇒ Course
Returns a new instance of Course.
11 12 13 14 15 16 |
# File 'lib/curricula.rb', line 11 def initialize name, hours @name = name @hours = hours @prereqs = [] @cruciality = 0 end |
Instance Attribute Details
#cruciality ⇒ Object
Returns the value of attribute cruciality.
9 10 11 |
# File 'lib/curricula.rb', line 9 def cruciality @cruciality end |
#hours ⇒ Object (readonly)
Returns the value of attribute hours.
8 9 10 |
# File 'lib/curricula.rb', line 8 def hours @hours end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/curricula.rb', line 8 def name @name end |
#prereqs ⇒ Object
Returns the value of attribute prereqs.
9 10 11 |
# File 'lib/curricula.rb', line 9 def prereqs @prereqs end |
Instance Method Details
#graph_edges ⇒ Object
18 19 20 |
# File 'lib/curricula.rb', line 18 def graph_edges prereqs.map{ |prereq| { source: prereq.name, destination: name } } end |