Class: Ovimap::Generators::HeatmapGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Helpers
Defined in:
lib/generators/ovimap/heatmap/heatmap_generator.rb

Constant Summary collapse

DATA_SET =
(2..@ending_row).to_a.map {|x|
"{value: #{sheet[x, :A].value}, latitude: #{sheet[x, :B].value}, longitude: #{sheet[x, :C].value}}" }
CLEANED_DATA =
DATA_SET.to_s.gsub /"/,''

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#asset_path, #content_for, #heatmap_options, #js_path, #layouts, #map_select, #map_style, #map_swap, #nokia_script, #pin_options, #stylesheets

Class Method Details

.source_rootObject



22
23
24
# File 'lib/generators/ovimap/heatmap/heatmap_generator.rb', line 22

def self.source_root
  @source_root ||= File.expand_path("../templates", __FILE__)
end

Instance Method Details

#heatmapObject



26
27
28
29
30
31
# File 'lib/generators/ovimap/heatmap/heatmap_generator.rb', line 26

def heatmap
  # unless File.readlines(#{js_path}/map.js).grep(/var data/).any?
  insert_into_file "#{js_path}/map.js", "\nvar data = #{CLEANED_DATA};", :after => /HEAT MAP DATA\/\//
  # end
  insert_into_file "#{js_path}/map.js", "\n#{heatmap_options}", :after => /HEAT MAP OPTIONS\/\//
end