Class: Ziya::Maps::Support::Base

Inherits:
Charts::Support::Base show all
Includes:
YamlHelpers::Gauges
Defined in:
lib/ziya/maps/support/base.rb

Instance Method Summary collapse

Methods included from YamlHelpers::Gauges

#dial, #dials, #gauge

Methods included from YamlHelpers::Base

#clazz, #indent

Methods inherited from Charts::Support::Base

#==, attributes, #attributes_for, #configured?, has_attribute, #has_sub_components, #initialize, #merge, #options, #options_as_string

Constructor Details

This class inherits a constructor from Ziya::Charts::Support::Base

Instance Method Details

#flatten(xml) ⇒ Object

flatten component to xml



8
9
10
11
12
# File 'lib/ziya/maps/support/base.rb', line 8

def flatten( xml )
  xml.state( :id => to_component_id ) do |state|
    options.keys.sort { |a,b| a.to_s <=> b.to_s }.each{ |k| self.class.module_eval "xml.#{k}( '#{options[k]}' )" }
  end
end

#to_comp_yaml(indent_multiplier = 1) ⇒ Object


converts component to yaml style component for yaml parser consumption



16
17
18
19
20
21
22
23
24
# File 'lib/ziya/maps/support/base.rb', line 16

def to_comp_yaml( indent_multiplier=1 )
  buff = []
  tab  = indent( indent_multiplier )
  buff << "#{dial( self.class.name.ziya_demodulize, name )}"      
  options.each_pair do |k,v|
    buff << "#{tab}#{k}: #{v}" if options[k] and !options[k].to_s.empty?
  end
  buff.join( "\n" )
end