Class: PictureTag::Instructions::CdnUrl

Inherits:
Instruction show all
Defined in:
lib/jekyll_picture_tag/instructions/children/config.rb

Overview

CDN URL

Instance Method Summary collapse

Methods inherited from Instruction

#value

Instance Method Details

#error_messageObject



106
107
108
109
110
111
# File 'lib/jekyll_picture_tag/instructions/children/config.rb', line 106

def error_message
  <<~HEREDOC
    cdn_url must be a valid URI in the following format: https://example.com/
    current setting: #{source}
  HEREDOC
end

#sourceObject



94
95
96
# File 'lib/jekyll_picture_tag/instructions/children/config.rb', line 94

def source
  PictureTag.pconfig['cdn_url']
end

#valid?Boolean

Returns:

  • (Boolean)


98
99
100
101
102
103
104
# File 'lib/jekyll_picture_tag/instructions/children/config.rb', line 98

def valid?
  require 'uri'
  uri = URI(source)

  # If the URI library can't parse it, it's not valid.
  uri.scheme && uri.host
end