class Dedalus::PatternLibrary::PeriodicTableEntry

Attributes

color[RW]
element_name[RW]
kind[RW]
scale[RW]

Public Class Methods

description() click to toggle source
# 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() click to toggle source
# File lib/dedalus/pattern_library/molecules/periodic_table_entry.rb, line 62
def self.example_data
  {
    element_abbreviation: "Ht",
    element_name: "Huge Text"
  }
end

Public Instance Methods

abbreviation() click to toggle source
# File lib/dedalus/pattern_library/molecules/periodic_table_entry.rb, line 21
def abbreviation
  if element_name.match(/ /) #split(" ").count > 0
    element_name.split(" ").map(&:first).join.capitalize
  else
    element_name.slice(0,2).capitalize
  end
end
background_color() click to toggle source
# 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() click to toggle source
# File lib/dedalus/pattern_library/molecules/periodic_table_entry.rb, line 29
def click
  view.route_to(element_name)
end
height() click to toggle source
# File lib/dedalus/pattern_library/molecules/periodic_table_entry.rb, line 45
def height
  300 * scale
end
margin() click to toggle source
# File lib/dedalus/pattern_library/molecules/periodic_table_entry.rb, line 33
def margin
  15 * scale
end
padding() click to toggle source
# File lib/dedalus/pattern_library/molecules/periodic_table_entry.rb, line 37
def padding
  30 * scale
end
show() click to toggle source
# 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() click to toggle source
# File lib/dedalus/pattern_library/molecules/periodic_table_entry.rb, line 41
def width
  260 * scale
end