Class: RefreshingmenusApi::Widget
- Inherits:
-
Object
- Object
- RefreshingmenusApi::Widget
- Defined in:
- lib/refreshingmenus_api/widget.rb
Class Method Summary collapse
- .script_src(options) ⇒ Object
-
.script_tag(options) ⇒ Object
Options: * widget_token (required) - Your RefreshingMenus Widget token * place_id (required) - The RefreshingMenus Place ID (UUID) * secure - Boolean, we’ll use https if true * style - The style name we should use (default: ‘default’), use ‘none’ for no styling (if you embed your own styling).
Class Method Details
.script_src(options) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/refreshingmenus_api/widget.rb', line 13 def self.script_src() = .clone # Don't fuck up Hash we don't own.. raise ArgumentError, "Expected options argument to be a Hash, got #{.inspect}." if not .is_a?(Hash) [:dom_id] = 'rm-menuwidget' raise ArgumentError, "Expected a :place_id as option but got #{[:place_id].inspect}." if not [:place_id].is_a?(String) raise ArgumentError, "Expected a :widget_token as option but got #{[:widget_token].inspect}." if not [:widget_token].is_a?(String) secure = .delete(:secure) version = .delete(:version) || '1' base_uri = .delete(:base_uri) || 'www.refreshingmenus.com' "#{secure ? 'https' : 'http'}://#{base_uri}/api/v#{version}/widget.js?#{.to_param}" end |
.script_tag(options) ⇒ Object
Options:
-
widget_token (required) - Your RefreshingMenus Widget token
-
place_id (required) - The RefreshingMenus Place ID (UUID)
-
secure - Boolean, we’ll use https if true
-
style - The style name we should use (default: ‘default’), use ‘none’ for no styling (if you embed your own styling)
9 10 11 |
# File 'lib/refreshingmenus_api/widget.rb', line 9 def self.script_tag() return "<script id='#{[:dom_id]}' src='#{self.src()}'></script>" end |