Class: Onebox::Engine::GoogleMapsOnebox

Inherits:
Object
  • Object
show all
Includes:
Onebox::Engine
Defined in:
lib/onebox/engine/google_maps_onebox.rb

Instance Attribute Summary

Attributes included from Onebox::Engine

#errors, #options, #timeout, #uri, #url

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Onebox::Engine

all_iframe_origins, engines, included, origins_to_regexes

Constructor Details

#initialize(url, timeout = nil) ⇒ GoogleMapsOnebox

Returns a new instance of GoogleMapsOnebox.



44
45
46
47
48
49
50
51
52
53
# File 'lib/onebox/engine/google_maps_onebox.rb', line 44

def initialize(url, timeout = nil)
  super
  resolve_url!
rescue Net::HTTPServerException,
       Timeout::Error,
       Net::HTTPError,
       Errno::ECONNREFUSED,
       RuntimeError => err
  raise ArgumentError, "malformed url or unresolveable: #{err.message}"
end

Class Method Details

.===(other) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/onebox/engine/google_maps_onebox.rb', line 9

def ===(other)
  if other.kind_of? URI
    @@matchers && @@matchers.any? { |m| other.to_s =~ m[:regexp] }
  else
    super
  end
end

Instance Method Details

#placeholder_htmlObject



63
64
65
# File 'lib/onebox/engine/google_maps_onebox.rb', line 63

def placeholder_html
  ::Onebox::Helpers.map_placeholder_html
end

#streetview?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/onebox/engine/google_maps_onebox.rb', line 55

def streetview?
  !!@streetview
end

#to_htmlObject



59
60
61
# File 'lib/onebox/engine/google_maps_onebox.rb', line 59

def to_html
  "<div class='maps-onebox'><iframe src=\"#{link}\" width=\"690\" height=\"400\" frameborder=\"0\" style=\"border:0\">#{placeholder_html}</iframe></div>"
end