Class: GoMaps::Direction

Inherits:
Object
  • Object
show all
Defined in:
lib/go_maps/direction.rb

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Direction

Returns a new instance of Direction.



3
4
5
6
# File 'lib/go_maps/direction.rb', line 3

def initialize(params)
  @from = params[:from]
  @to = params[:to]
end

Instance Method Details

#to_html(options = {}) ⇒ Object



14
15
16
# File 'lib/go_maps/direction.rb', line 14

def to_html(options = {})
  Address.new(@from).route_to(@to, :language => options[:language])['steps'].map { |step| "<div class=\"step\">#{step['html_instructions']}</div>" }.join
end

#to_map(options = {}) ⇒ Object



8
9
10
11
12
# File 'lib/go_maps/direction.rb', line 8

def to_map(options = {})
  options[:width] ||= 425
  options[:height] ||= 350
  "<iframe width='#{options[:width]}' height='#{options[:height]}' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='#{map_url(@from, @to)}'></iframe>"
end