Class: Fet::Degree
- Inherits:
-
Object
- Object
- Fet::Degree
- Defined in:
- lib/fet/degree.rb
Overview
This class handles validation of degree names and extraction of values from it
Constant Summary collapse
- DEGREE_NAMES =
[ ["1"], ["#1", "b2"], ["2"], ["#2", "b3"], ["3"], ["4"], ["#4", "b5"], ["5"], ["#5", "b6"], ["6"], ["#6", "b7"], ["7"], ].deep_freeze
Instance Attribute Summary collapse
-
#degree_name ⇒ Object
readonly
Returns the value of attribute degree_name.
Instance Method Summary collapse
- #degree_accidental ⇒ Object
- #degree_index ⇒ Object
- #degree_value ⇒ Object
-
#initialize(degree_name) ⇒ Degree
constructor
A new instance of Degree.
Constructor Details
#initialize(degree_name) ⇒ Degree
Returns a new instance of Degree.
23 24 25 26 |
# File 'lib/fet/degree.rb', line 23 def initialize(degree_name) self.degree_name = degree_name validate_degree_name! end |
Instance Attribute Details
#degree_name ⇒ Object
Returns the value of attribute degree_name.
21 22 23 |
# File 'lib/fet/degree.rb', line 21 def degree_name @degree_name end |
Instance Method Details
#degree_accidental ⇒ Object
28 29 30 |
# File 'lib/fet/degree.rb', line 28 def degree_accidental return degree_name.size == 2 ? degree_name[0] : nil end |
#degree_index ⇒ Object
36 37 38 |
# File 'lib/fet/degree.rb', line 36 def degree_index return DEGREE_NAMES.index { |degree_names| degree_names.include?(degree_name) } end |
#degree_value ⇒ Object
32 33 34 |
# File 'lib/fet/degree.rb', line 32 def degree_value return degree_name.size == 2 ? degree_name[1].to_i : degree_name[0].to_i end |