Class: CodeApe::Section
- Inherits:
-
Object
- Object
- CodeApe::Section
- Defined in:
- lib/code_ape/section.rb
Overview
Represent section of ape code (A letter assigned to a subdivision grouping not represented in the final ape code)
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 section of this ape code.
-
#divisions ⇒ Array<CodeApe::Division>
The divisions associated with section of this ape code.
-
#groups ⇒ Array<CodeApe::Group>
The groups associated with section of this ape code.
-
#initialize(key, label) ⇒ Section
constructor
Creates a new Section.
-
#subsections ⇒ Array<CodeApe::Subsection>
The subsections associated with section of this ape code.
-
#to_h ⇒ Hash
The hash representation of section label.
Constructor Details
#initialize(key, label) ⇒ Section
Creates a new CodeApe::Section
9 10 11 12 |
# File 'lib/code_ape/section.rb', line 9 def initialize(key, label) @key = key.to_s @label = label end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
4 5 6 |
# File 'lib/code_ape/section.rb', line 4 def key @key end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
4 5 6 |
# File 'lib/code_ape/section.rb', line 4 def label @label end |
Instance Method Details
#classes ⇒ Array<CodeApe::Class>
Returns the classes associated with section of this ape code.
15 16 17 |
# File 'lib/code_ape/section.rb', line 15 def classes @classes ||= CLASSES.select { |e| e.section_key == @key } end |
#divisions ⇒ Array<CodeApe::Division>
Returns the divisions associated with section of this ape code.
25 26 27 |
# File 'lib/code_ape/section.rb', line 25 def divisions @divisions ||= DIVISIONS.select { |e| classes.map(&:division_key).include?(e.key) } end |
#groups ⇒ Array<CodeApe::Group>
Returns the groups associated with section of this ape code.
20 21 22 |
# File 'lib/code_ape/section.rb', line 20 def groups @groups ||= GROUPS.select { |e| classes.map(&:group_key).include?(e.key) } end |
#subsections ⇒ Array<CodeApe::Subsection>
Returns the subsections associated with section of this ape code.
30 31 32 |
# File 'lib/code_ape/section.rb', line 30 def subsections @subsections ||= SUBSECTIONS.select { |e| classes.map(&:subsection_key).include?(e.key) } end |
#to_h ⇒ Hash
Returns the hash representation of section label.
35 36 37 |
# File 'lib/code_ape/section.rb', line 35 def to_h {label: @label} end |