Class: Dedalus::PatternLibrary::LibraryEntry
- Defined in:
- lib/dedalus/pattern_library/organisms/library_entry.rb
Instance Attribute Summary collapse
-
#color ⇒ Object
Returns the value of attribute color.
-
#description ⇒ Object
Returns the value of attribute description.
-
#item ⇒ Object
Returns the value of attribute item.
-
#items ⇒ Object
Returns the value of attribute items.
-
#show_table ⇒ Object
Returns the value of attribute show_table.
-
#subtitle ⇒ Object
Returns the value of attribute subtitle.
-
#title ⇒ Object
Returns the value of attribute title.
Attributes inherited from Element
#height, #height_percent, #margin, #offset, #position, #shown, #width, #width_percent, #z_order
Class Method Summary collapse
Instance Method Summary collapse
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
#color ⇒ Object
Returns the value of attribute color.
4 5 6 |
# File 'lib/dedalus/pattern_library/organisms/library_entry.rb', line 4 def color @color end |
#description ⇒ Object
Returns the value of attribute description.
4 5 6 |
# File 'lib/dedalus/pattern_library/organisms/library_entry.rb', line 4 def description @description end |
#item ⇒ Object
Returns the value of attribute item.
4 5 6 |
# File 'lib/dedalus/pattern_library/organisms/library_entry.rb', line 4 def item @item end |
#items ⇒ Object
Returns the value of attribute items.
4 5 6 |
# File 'lib/dedalus/pattern_library/organisms/library_entry.rb', line 4 def items @items end |
#show_table ⇒ Object
Returns the value of attribute show_table.
4 5 6 |
# File 'lib/dedalus/pattern_library/organisms/library_entry.rb', line 4 def show_table @show_table end |
#subtitle ⇒ Object
Returns the value of attribute subtitle.
4 5 6 |
# File 'lib/dedalus/pattern_library/organisms/library_entry.rb', line 4 def subtitle @subtitle end |
#title ⇒ Object
Returns the value of attribute title.
4 5 6 |
# File 'lib/dedalus/pattern_library/organisms/library_entry.rb', line 4 def title @title end |
Class Method Details
.description ⇒ Object
49 50 51 |
# File 'lib/dedalus/pattern_library/organisms/library_entry.rb', line 49 def self.description "An entry in a library" end |
.example_data ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/dedalus/pattern_library/organisms/library_entry.rb', line 53 def self.example_data { title: "Welcome", subtitle: "world", description: "Welcome to this section", color: "darkblue", items: [ LibraryItemExample.example_data ] } end |
.from_item(item) ⇒ Object
6 7 8 |
# File 'lib/dedalus/pattern_library/organisms/library_entry.rb', line 6 def self.from_item(item) new(title: item[:name], subtitle: item[:description], item: item) end |
Instance Method Details
#background_color ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/dedalus/pattern_library/organisms/library_entry.rb', line 41 def background_color if color Palette.decode_color(color).lighten elsif item && item[:color] Palette.decode_color(item[:color]) end end |
#library_items ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/dedalus/pattern_library/organisms/library_entry.rb', line 18 def library_items if items if show_table PeriodicTable.new(elements: items) else # items items.map do |name:, description:, item_class_name:, item_data:, kind:, color:| PeriodicTableEntry.new( element_name: name, color: color, kind: kind) end end elsif item LibraryItemExample.new(item) else [] end end |
#padding ⇒ Object
37 38 39 |
# File 'lib/dedalus/pattern_library/organisms/library_entry.rb', line 37 def padding @padding ||= 40 end |