Class: Dedalus::PatternLibrary::PeriodicTable

Inherits:
Molecule show all
Defined in:
lib/dedalus/pattern_library/molecules/periodic_table.rb

Instance Attribute Summary collapse

Attributes inherited from Element

#background_color, #color, #height, #height_percent, #margin, #offset, #padding, #position, #shown, #width, #width_percent, #z_order

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Molecule

#click, #hover

Methods inherited from Element

#big_font, #code_font, #draw_bounding_box, #font, #huge_font, #initialize, #record?, #tiny_font, #view, #window

Constructor Details

This class inherits a constructor from Dedalus::Element

Instance Attribute Details

#elementsObject

Returns the value of attribute elements.



4
5
6
# File 'lib/dedalus/pattern_library/molecules/periodic_table.rb', line 4

def elements
  @elements
end

Class Method Details

.descriptionObject



23
24
25
# File 'lib/dedalus/pattern_library/molecules/periodic_table.rb', line 23

def self.description
  "A collection of elements"
end

.example_dataObject



27
28
29
# File 'lib/dedalus/pattern_library/molecules/periodic_table.rb', line 27

def self.example_data
  { elements: Array.new(4) { LibraryItemExample.example_data } }
end

Instance Method Details

#element_groupsObject



19
20
21
# File 'lib/dedalus/pattern_library/molecules/periodic_table.rb', line 19

def element_groups
  elements.group_by { |elem| elem[:kind] }
end

#showObject



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/dedalus/pattern_library/molecules/periodic_table.rb', line 6

def show
  self.element_groups.map do |_, grouped_elements|
    grouped_elements.map do |name:, color:, kind:, **|
      PeriodicTableEntry.new(
        element_name: name,
        color: color,
        kind: kind,
        scale: 0.35
      )
    end
  end
end