Class: PwaManifestGenerator::UrlHandler
- Inherits:
-
Object
- Object
- PwaManifestGenerator::UrlHandler
- Includes:
- Freezeable
- Defined in:
- lib/pwa_manifest_generator/url_handler.rb
Instance Attribute Summary collapse
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
-
#initialize ⇒ UrlHandler
constructor
A new instance of UrlHandler.
- #to_html ⇒ Object
- #valid? ⇒ Boolean
Methods included from Freezeable
Constructor Details
#initialize ⇒ UrlHandler
Returns a new instance of UrlHandler.
11 12 13 |
# File 'lib/pwa_manifest_generator/url_handler.rb', line 11 def initialize @scope = Struct.new(:matches, :launch_url).new([], 'https://localhost:3000') end |
Instance Attribute Details
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
9 10 11 |
# File 'lib/pwa_manifest_generator/url_handler.rb', line 9 def scope @scope end |
Instance Method Details
#to_html ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/pwa_manifest_generator/url_handler.rb', line 22 def to_html json = { scope: { matches: @scope.matches, launch_url: @scope.launch_url } }.to_json json.respond_to?(:html_safe) ? json.html_safe : json end |
#valid? ⇒ Boolean
15 16 17 18 19 20 |
# File 'lib/pwa_manifest_generator/url_handler.rb', line 15 def valid? @scope.matches.all? do |match| match.is_a?(String) && match.start_with?('http://', 'https://') end && @scope.launch_url.is_a?(String) && @scope.launch_url.start_with?('http://', 'https://') end |