lib/ziya/helpers/base_helper.rb in derailed-ziya-2.0.4 vs lib/ziya/helpers/base_helper.rb in derailed-ziya-2.0.6
- old
+ new
@@ -3,68 +3,89 @@
module Ziya::Helpers
module BaseHelper
include Ziya::Utils::Text, Ziya::Helper
- # -------------------------------------------------------------------------
- # generates a swf chart path from the given url. Used as helper to embed
- # chart
+ # Defines various helpers to assist in writing ZiYa yaml stylesheets.
+
+ # generates a swf chart path from the given url. Used as helper to embed a chart
+ # within a chart
+ # ==== Example
+ # <%= chart_url( chart_1_path ) %>
+ #
+ # => /charts/charts.swf?library_path=/charts/charts_library&xml_source=http://fred/load_chart_1.xml
def chart_url( url, swf_chart_dir="/charts" )
gen_composite_path( swf_chart_dir, url )
end
- # -------------------------------------------------------------------------
# indent yaml content vy multiples of 2 spaces
def indent( multiple= 1 )
" " * multiple
end
- # -------------------------------------------------------------------------
- # YAML Convenience for gauge class
+ # generates a gauge yaml class declaration
+ # ==== Example
+ # <%= gauge :thermo %>
+ #
+ # produces:
+ #
+ # --- !ruby/object:Ziya::Gauges::Thermo
+ # components: !omap
def gauge( class_name )
"--- #{clazz( class_name, 'Gauges' )}\n#{dials}"
end
- # -------------------------------------------------------------------------
- # YAML Convenience for gauge component declaration
+ # generates a gauge element declaration
+ # ==== Example
+ # <%= dial :rect %>
+ # => --- !ruby/object:Ziya::Gauges::Support::Rect
def dial( comp_class, comp_name=nil )
clazz = clazz( comp_class, "Gauges::Support" )
comp_name ? "- :#{comp_name}: #{clazz}" : "- #{clazz}"
end
- # -------------------------------------------------------------------------
- # YAML dials declaration
+ # generates a yaml hash of dials
+ # ==== Example
+ # <%= dials %>
+ # => components: !omap
def dials
"components: !omap"
end
- # -------------------------------------------------------------------------
- # YAML Convenience for component declaration
+ # generates a component yaml class declaration
+ # ==== Example
+ # <%= component :axis_category %>
+ # => axis_category: --- !ruby/object:Ziya::Components::AxisCategory
def component( component_name )
"#{component_name}: #{clazz component_name, :Components}"
end
alias :comp :component
- # -------------------------------------------------------------------------
- # YAML Convenience for draw component class
+ # generates a drawing yaml class declaration
+ # ==== Example
+ # <%=drawing :rect %>
+ # => --- !ruby/object:Ziya::Components::Rect
def drawing( class_name )
clazz( class_name, :Components )
end
alias_method :filter_type, :drawing
alias_method :area , :drawing
- # -------------------------------------------------------------------------
- # YAML Convenience for chart class
+ # generates a yaml chart declaration
+ # ==== Example
+ # <%= chart :bar %>
+ # => --- !ruby/object:Ziya::Charts::Bar
def chart( class_name )
"--- #{clazz( class_name, :Charts )}"
end
-
- # -------------------------------------------------------------------------
- # YAML Convenience for chart name setting
- def clazz( class_name, module_name=nil )
- buff = "!ruby/object:Ziya::"
- buff << "#{module_name}::" unless module_name.nil?
- buff << "#{camelize(class_name.to_s)}"
- buff
- end
+
+ private
+
+ # generates a yaml class declaration
+ def clazz( class_name, module_name=nil ) #:nodoc:
+ buff = "!ruby/object:Ziya::"
+ buff << "#{module_name}::" unless module_name.nil?
+ buff << "#{camelize(class_name.to_s)}"
+ buff
+ end
end
end
\ No newline at end of file