Sha256: f6fbd4bba391163fc47adf0e174fa37ce3542e9ada9e06537895ad186f251dcb
Contents?: true
Size: 1.01 KB
Versions: 2
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true require 'link_thumbnailer/model' module LinkThumbnailer module Models class Website < ::LinkThumbnailer::Model attr_accessor :url, :title, :description, :images, :videos, :favicon def initialize @images = [] @videos = [] end def video=(video) self.videos = video end def videos=(videos) Array(videos).each do |video| @videos << video end end def image=(image) self.images = image end def images=(images) Array(images).each do |image| next unless image.valid? @images << image end end def images @images.sort! end def as_json(*) { url: url.to_s, favicon: favicon, title: title, description: description, images: images.map(&:as_json), videos: videos.map(&:as_json) } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
link_thumbnailer-3.4.0 | lib/link_thumbnailer/models/website.rb |
link_thumbnailer-3.3.2 | lib/link_thumbnailer/models/website.rb |