Class: Dedalus::PatternLibrary::LibraryItemExample

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

Instance Attribute Summary collapse

Attributes inherited from Element

#height, #height_percent, #margin, #offset, #padding, #position, #shown, #width, #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

#colorObject

Returns the value of attribute color.



8
9
10
# File 'lib/dedalus/pattern_library/molecules/library_item_example.rb', line 8

def color
  @color
end

#item_class_nameObject

Returns the value of attribute item_class_name.



5
6
7
# File 'lib/dedalus/pattern_library/molecules/library_item_example.rb', line 5

def item_class_name
  @item_class_name
end

#item_dataObject

Returns the value of attribute item_data.



6
7
8
# File 'lib/dedalus/pattern_library/molecules/library_item_example.rb', line 6

def item_data
  @item_data
end

#kindObject

Returns the value of attribute kind.



7
8
9
# File 'lib/dedalus/pattern_library/molecules/library_item_example.rb', line 7

def kind
  @kind
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

Class Method Details

.descriptionObject



47
48
49
# File 'lib/dedalus/pattern_library/molecules/library_item_example.rb', line 47

def self.description
  "an example of a pattern"
end

.example_dataObject



51
52
53
54
55
56
57
58
59
60
# File 'lib/dedalus/pattern_library/molecules/library_item_example.rb', line 51

def self.example_data
  {
    name: "Huge Text",
    description: "(fake library item molecule)",
    item_class_name: 'Dedalus::PatternLibrary::HugeText',
    item_data: { text: "Hi there!" },
    color: 'red', #Palette.red,
    kind: 'Atom'
  }
end

Instance Method Details

#background_colorObject



43
44
45
# File 'lib/dedalus/pattern_library/molecules/library_item_example.rb', line 43

def background_color
  nil
end

#exampleObject



26
27
28
29
30
31
32
33
# File 'lib/dedalus/pattern_library/molecules/library_item_example.rb', line 26

def example
  [
    LargeText.new(text: "EXAMPLE", height_percent: 0.05, color: color),
    item,
    LargeText.new(text: "DATA", height_percent: 0.05, color: color),
    Code.new(text: item_data, background_color: Palette.decode_color('darkgray'), padding: 10)
  ]
end

#itemObject



35
36
37
# File 'lib/dedalus/pattern_library/molecules/library_item_example.rb', line 35

def item
  item_class_name.constantize.new(item_data)
end

#periodic_table_entryObject



17
18
19
20
21
22
23
24
# File 'lib/dedalus/pattern_library/molecules/library_item_example.rb', line 17

def periodic_table_entry
  PeriodicTableEntry.new(
    element_name: name,
    color: color,
    kind: kind,
    scale: 1.8
  )
end

#showObject



10
11
12
13
14
15
# File 'lib/dedalus/pattern_library/molecules/library_item_example.rb', line 10

def show
  [[
    periodic_table_entry,
    example
  ]]
end

#width_percentObject



39
40
41
# File 'lib/dedalus/pattern_library/molecules/library_item_example.rb', line 39

def width_percent
  0.6
end