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, #code_font, #draw_bounding_box, #font, #huge_font, #initialize, #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.
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
35 36 37 |
# File 'lib/dedalus/pattern_library/molecules/library_item_example.rb', line 35 def self.description "an example of a pattern" end |
.example_data ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/dedalus/pattern_library/molecules/library_item_example.rb', line 39 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
27 28 29 30 31 32 33 |
# File 'lib/dedalus/pattern_library/molecules/library_item_example.rb', line 27 def background_color if color Palette.decode_color(color).darken else Palette.gray end end |
#item ⇒ Object
19 20 21 |
# File 'lib/dedalus/pattern_library/molecules/library_item_example.rb', line 19 def item item_class_name.constantize.new(item_data) end |
#show ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/dedalus/pattern_library/molecules/library_item_example.rb', line 10 def show [ TinyText.new(text: "EXAMPLE", height_percent: 0.05, background_color: background_color.darken), item, TinyText.new(text: "DATA", height_percent: 0.05, background_color: background_color.darken), Code.new(text: item_data, background_color: Palette.decode_color('darkgray'), padding: 10) ] end |
#width_percent ⇒ Object
23 24 25 |
# File 'lib/dedalus/pattern_library/molecules/library_item_example.rb', line 23 def width_percent 0.6 end |