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