Class: YMaps::ActionView::YMapsReprBuilder

Inherits:
YMapsBuilder show all
Defined in:
lib/ymaps/action_view/ymapsml_helper.rb

Constant Summary collapse

ACCEPTABLE_STYLES =
{
  :balloon_content => [:template],
  :hint_content => [:template],
  :icon => [:href, :offset, :shadow, :size, :template],
  :icon_content => [:template],
  :line => [:stroke_color, :stroke_width],
  :polygon => [:fill, :fill_color, :outline, :stroke_color, :stroke_width],
}

Constants inherited from Builder

Builder::GML_TAG_NAMES, Builder::REPR_TAG_NAMES, Builder::YMAPS_TAG_NAMES

Instance Method Summary collapse

Methods inherited from YMapsBuilder

#bounds, #collection, #initialize, #meta_data, #object, #point, #representation

Methods inherited from Builder

#initialize

Constructor Details

This class inherits a constructor from YMaps::ActionView::YMapsBuilder

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class YMaps::ActionView::Builder

Instance Method Details

#style(id, options = {}) ⇒ Object

Add style definition


144
145
146
147
148
149
150
151
152
# File 'lib/ymaps/action_view/ymapsml_helper.rb', line 144

def style(id, options = {})
  options[:hasBalloon]  = options.delete(:balloon)  if options.key?(:balloon)
  options[:hasHint]     = options.delete(:hint)     if options.key?(:hint)
  parent                = options.delete(:parent) { false  }
  Style(options.merge('gml:id' => id.to_s)) {
    link_to(:parentStyle, parent) if parent
    yield
  }
end

#template(id, template_text = nil) ⇒ Object


163
164
165
166
167
168
169
# File 'lib/ymaps/action_view/ymapsml_helper.rb', line 163

def template(id, template_text = nil)
  Template('gml:id' => id.to_s) do
    text do
      cdata!(template_text || yield)
    end
  end
end

#view(options = {}) ⇒ Object


133
134
135
136
137
138
139
# File 'lib/ymaps/action_view/ymapsml_helper.rb', line 133

def view(options = {})
  View {
    mapType(options[:type].to_s.upcase) if options[:type]
    bounds(options[:bounds]) if options[:bounds]
    yield if block_given?
  }
end