Sha256: f72e6bf2fc50cea61ca8ae976c6884a4419520c04d2f174858fb5253506a8495
Contents?: true
Size: 1.52 KB
Versions: 4
Compression:
Stored size: 1.52 KB
Contents
module Dogviz module Common def create_id(name, parent) parts = [] parts << parent.id if parent.respond_to? :id parts += name.split /\s/ parts.join '_' end def root ancestors.last end def ancestors ancestors = [parent] loop do break unless ancestors.last.respond_to?(:parent) ancestors << ancestors.last.parent end ancestors end def info(fields) @info.merge! fields setup_render_attributes(label: label_with_info) end def doclink(url) setup_render_attributes(URL: url) end def label_with_info lines = [name] @info.each { |k, v| lines << "#{k}: #{v}" } lines.join "\n" end def setup_render_attributes(attributes) @attributes = {} if @attributes.nil? @attributes.merge!(attributes) end def rollup? @rollup end def rollup! @rollup = true self end def skip! @skip = true self end def skip? @skip end def in_skip? skip? || under_skip? end def under_skip? ancestors.any? &:skip? end def under_rollup? ancestors.any? &:rollup? end def in_rollup? rollup? || under_rollup? end def on_top_rollup? rollup? && !under_rollup? end def inherited_render_options inherited = {} inherited[:fontname] = parent.render_options[:fontname] if parent.render_options.include?(:fontname) inherited end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
dogviz-0.0.21 | lib/dogviz/common.rb |
dogviz-0.0.20 | lib/dogviz/common.rb |
dogviz-0.0.19 | lib/dogviz/common.rb |
dogviz-0.0.18 | lib/dogviz/common.rb |