Class: Dedalus::PatternLibrary::PeriodicTableEntry
- Inherits:
-
Molecule
show all
- Defined in:
- lib/dedalus/pattern_library/molecules/periodic_table_entry.rb
Instance Attribute Summary collapse
Attributes inherited from Element
#height_percent, #offset, #position, #shown, #width_percent, #z_order
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Molecule
#hover
Methods inherited from Element
#big_font, #code_font, #draw_bounding_box, #font, #huge_font, #initialize, #record?, #tiny_font, #view, #window
Instance Attribute Details
#color ⇒ Object
Returns the value of attribute color.
6
7
8
|
# File 'lib/dedalus/pattern_library/molecules/periodic_table_entry.rb', line 6
def color
@color
end
|
#element_name ⇒ Object
Returns the value of attribute element_name.
4
5
6
|
# File 'lib/dedalus/pattern_library/molecules/periodic_table_entry.rb', line 4
def element_name
@element_name
end
|
#kind ⇒ Object
Returns the value of attribute kind.
5
6
7
|
# File 'lib/dedalus/pattern_library/molecules/periodic_table_entry.rb', line 5
def kind
@kind
end
|
#scale ⇒ Object
Returns the value of attribute scale.
7
8
9
|
# File 'lib/dedalus/pattern_library/molecules/periodic_table_entry.rb', line 7
def scale
@scale
end
|
Class Method Details
.description ⇒ Object
58
59
60
|
# File 'lib/dedalus/pattern_library/molecules/periodic_table_entry.rb', line 58
def self.description
"a high-level view of an element"
end
|
.example_data ⇒ Object
62
63
64
65
66
67
|
# File 'lib/dedalus/pattern_library/molecules/periodic_table_entry.rb', line 62
def self.example_data
{
element_abbreviation: "Ht",
element_name: "Huge Text"
}
end
|
Instance Method Details
#abbreviation ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/dedalus/pattern_library/molecules/periodic_table_entry.rb', line 21
def abbreviation
if element_name.match(/ /) element_name.split(" ").map(&:first).join.capitalize
else
element_name.slice(0,2).capitalize
end
end
|
#background_color ⇒ Object
49
50
51
52
53
54
55
56
|
# File 'lib/dedalus/pattern_library/molecules/periodic_table_entry.rb', line 49
def background_color
if color
c = Palette.decode_color(color) if color.is_a?(String)
c.darken
else
Palette.gray
end
end
|
#click ⇒ Object
29
30
31
|
# File 'lib/dedalus/pattern_library/molecules/periodic_table_entry.rb', line 29
def click
view.route_to(element_name)
end
|
#height ⇒ Object
45
46
47
|
# File 'lib/dedalus/pattern_library/molecules/periodic_table_entry.rb', line 45
def height
300 * scale
end
|
#margin ⇒ Object
33
34
35
|
# File 'lib/dedalus/pattern_library/molecules/periodic_table_entry.rb', line 33
def margin
15 * scale
end
|
#padding ⇒ Object
37
38
39
|
# File 'lib/dedalus/pattern_library/molecules/periodic_table_entry.rb', line 37
def padding
30 * scale
end
|
#show ⇒ Object
9
10
11
12
13
14
15
|
# File 'lib/dedalus/pattern_library/molecules/periodic_table_entry.rb', line 9
def show
[
HugeText.new(text: abbreviation, scale: scale),
LargeText.new(text: element_name, scale: scale),
TinyText.new(text: kind, scale: scale)
]
end
|
#width ⇒ Object
41
42
43
|
# File 'lib/dedalus/pattern_library/molecules/periodic_table_entry.rb', line 41
def width
260 * scale
end
|