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