Class: Dedalus::PatternLibrary::LibraryItemExample
- Defined in:
- lib/dedalus/pattern_library/molecules/library_item_example.rb
Instance Attribute Summary collapse
-
#color ⇒ Object
Returns the value of attribute color.
-
#item_class_name ⇒ Object
Returns the value of attribute item_class_name.
-
#item_data ⇒ Object
Returns the value of attribute item_data.
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#name ⇒ Object
Returns the value of attribute name.
Attributes inherited from Element
#height, #height_percent, #margin, #padding, #position, #width
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Molecule
Methods inherited from Element
#big_font, #draw_bounding_box, #font, #huge_font, #initialize, #view, #window
Constructor Details
This class inherits a constructor from Dedalus::Element
Instance Attribute Details
#color ⇒ Object
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_name ⇒ Object
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_data ⇒ Object
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 |
#kind ⇒ Object
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 |
#name ⇒ Object
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
.description ⇒ Object
34 35 36 |
# File 'lib/dedalus/pattern_library/molecules/library_item_example.rb', line 34 def self.description "an example of a pattern" end |
.example_data ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/dedalus/pattern_library/molecules/library_item_example.rb', line 38 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_color ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/dedalus/pattern_library/molecules/library_item_example.rb', line 26 def background_color if color Palette.decode_color(color).darken else Palette.gray end end |
#item ⇒ Object
18 19 20 |
# File 'lib/dedalus/pattern_library/molecules/library_item_example.rb', line 18 def item item_class_name.constantize.new(item_data) end |
#show ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/dedalus/pattern_library/molecules/library_item_example.rb', line 10 def show [ Elements::Paragraph.new(text: "EXAMPLE", scale: 0.5, height_percent: 0.05, background_color: background_color.darken), item, Elements::Paragraph.new(text: item_data, scale: 0.7, background_color: Palette.decode_color('darkgray'), padding: 10) ] end |
#width_percent ⇒ Object
22 23 24 |
# File 'lib/dedalus/pattern_library/molecules/library_item_example.rb', line 22 def width_percent 0.6 end |