class HtmlCssToImage::Data::Image
Attributes
url[RW]
Public Class Methods
from(data)
click to toggle source
# File lib/html_css_to_image/data/image.rb, line 8 def self.from(data) raise ArgumentError.new "Key :url does not exist" unless data.key?(:url) Image.new(url: data[:url]) end
new(url:)
click to toggle source
# File lib/html_css_to_image/data/image.rb, line 14 def initialize(url:) url = URI(url) raise ArgumentError.new "Not https" unless url.scheme == HtmlCssToImage::API_SCHEME raise ArgumentError.new "Not HCTI API" unless url.host == HtmlCssToImage::API_HOST @url = url end
Public Instance Methods
id()
click to toggle source
# File lib/html_css_to_image/data/image.rb, line 23 def id url = @url.to_s i = url.rindex('/') + 1 url[i..-1] end