Class: CodeApe::Class

Inherits:
Object
  • Object
show all
Defined in:
lib/code_ape/class.rb

Overview

Represent final ape code (all digits + letter)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, label, section_key, subsection_key, division_key, group_key) ⇒ Class

Creates a new CodeApe::Class

Parameters:

  • key (Symbol, String)

    The class key of ape code

  • label (String)

    The class label of ape code

  • section_key (Symbol, String)

    The section key of ape code

  • subsection_key (Symbol, String)

    The subsection key of ape code

  • division_key (Symbol, String)

    The division key of ape code

  • group_key (Symbol, String)

    The group key of ape code



17
18
19
20
21
22
23
24
# File 'lib/code_ape/class.rb', line 17

def initialize(key, label, section_key, subsection_key, division_key, group_key)
  @key = key.to_s
  @label = label
  @section_key = section_key.to_s
  @subsection_key = subsection_key.to_s
  @division_key = division_key.to_s
  @group_key = group_key.to_s
end

Instance Attribute Details

#division_keyObject (readonly)

Returns the value of attribute division_key.



8
9
10
# File 'lib/code_ape/class.rb', line 8

def division_key
  @division_key
end

#group_keyObject (readonly)

Returns the value of attribute group_key.



8
9
10
# File 'lib/code_ape/class.rb', line 8

def group_key
  @group_key
end

#keyObject (readonly)

Returns the value of attribute key.



7
8
9
# File 'lib/code_ape/class.rb', line 7

def key
  @key
end

#labelObject (readonly)

Returns the value of attribute label.



7
8
9
# File 'lib/code_ape/class.rb', line 7

def label
  @label
end

#section_keyObject (readonly)

Returns the value of attribute section_key.



8
9
10
# File 'lib/code_ape/class.rb', line 8

def section_key
  @section_key
end

#subsection_keyObject (readonly)

Returns the value of attribute subsection_key.



8
9
10
# File 'lib/code_ape/class.rb', line 8

def subsection_key
  @subsection_key
end

Instance Method Details

#divisionCodeApe::Division

Returns the division of this ape code.

Returns:



32
33
34
# File 'lib/code_ape/class.rb', line 32

def division
  @division ||= DIVISIONS.find { |e| e.key == @division_key }
end

#groupCodeApe::Group

Returns the group of this ape code.

Returns:



27
28
29
# File 'lib/code_ape/class.rb', line 27

def group
  @group ||= GROUPS.find { |e| e.key == @group_key }
end

#sectionCodeApe::Section

Returns the section of this ape code.

Returns:



42
43
44
# File 'lib/code_ape/class.rb', line 42

def section
  @section ||= SECTIONS.find { |e| e.key == @section_key }
end

#subsectionCodeApe::Subsection

Returns the subsection of this ape code.

Returns:



37
38
39
# File 'lib/code_ape/class.rb', line 37

def subsection
  @subsection ||= SUBSECTIONS.find { |e| e.key == @subsection_key }
end

#to_hHash

Returns the hash representation of class label.

Returns:

  • (Hash)

    the hash representation of class label



47
48
49
# File 'lib/code_ape/class.rb', line 47

def to_h
  {label: @label}
end