Class: CodeApe::Division
- Inherits:
-
Object
- Object
- CodeApe::Division
- Defined in:
- lib/code_ape/division.rb
Overview
Represent division of ape code (first 3 digits)
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
Instance Method Summary collapse
-
#classes ⇒ Array<CodeApe::Class>
The classes associated with division of this ape code.
-
#groups ⇒ Array<CodeApe::Group>
The groups associated with division of this ape code.
-
#initialize(key, label) ⇒ Division
constructor
Creates a new Division.
-
#section ⇒ CodeApe::Section
The section of this ape code.
-
#subsection ⇒ CodeApe::Subsection
The subsection of this ape code.
-
#to_h ⇒ Hash
The hash representation of division label.
Constructor Details
#initialize(key, label) ⇒ Division
Creates a new CodeApe::Division
12 13 14 15 |
# File 'lib/code_ape/division.rb', line 12 def initialize(key, label) @key = key.to_s @label = label end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
7 8 9 |
# File 'lib/code_ape/division.rb', line 7 def key @key end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
7 8 9 |
# File 'lib/code_ape/division.rb', line 7 def label @label end |
Instance Method Details
#classes ⇒ Array<CodeApe::Class>
Returns the classes associated with division of this ape code.
18 19 20 |
# File 'lib/code_ape/division.rb', line 18 def classes @classes ||= CLASSES.select { |e| e.division_key == @key } end |
#groups ⇒ Array<CodeApe::Group>
Returns the groups associated with division of this ape code.
23 24 25 |
# File 'lib/code_ape/division.rb', line 23 def groups @groups ||= GROUPS.select { |e| classes.map(&:group_key).include?(e.key) } end |
#section ⇒ CodeApe::Section
Returns the section of this ape code.
33 34 35 |
# File 'lib/code_ape/division.rb', line 33 def section @section ||= SECTIONS.find { |e| e.key == classes[0]&.section_key } end |
#subsection ⇒ CodeApe::Subsection
Returns the subsection of this ape code.
28 29 30 |
# File 'lib/code_ape/division.rb', line 28 def subsection @subsection ||= SUBSECTIONS.find { |e| e.key == classes[0]&.subsection_key } end |
#to_h ⇒ Hash
Returns the hash representation of division label.
38 39 40 |
# File 'lib/code_ape/division.rb', line 38 def to_h {label: @label} end |