class NetworkDrawer::Element::Element
Replesent of element
Constants
- DEFAULT_STYLE
Public Class Methods
generate_id()
click to toggle source
# File lib/network_drawer/element/element.rb, line 13 def generate_id @ids ? @ids += 1 : @ids = 0 end
new(initial_values = {}, style = {})
click to toggle source
Calls superclass method
# File lib/network_drawer/element/element.rb, line 18 def initialize(initial_values = {}, style = {}) super(initial_values) self.id = self.class.generate_id @default_style = DEFAULT_STYLE @style = style end
Public Instance Methods
to_hash()
click to toggle source
# File lib/network_drawer/element/element.rb, line 25 def to_hash hash = {} self.each_pair do |k, v| hash.merge!(k.to_sym => v) unless k.to_sym == name end hash end
Private Instance Methods
style(type)
click to toggle source
# File lib/network_drawer/element/element.rb, line 35 def style(type) # TODO: select multiple types type = type.to_sym if type style = @style ? @style[type] : {} style ? @default_style.merge(style) : @default_style end