Sha256: 79fd6f264931e979b0295f4d6372b624006d046bf39954e3e56b06c13f288d6a
Contents?: true
Size: 1010 Bytes
Versions: 3
Compression:
Stored size: 1010 Bytes
Contents
# frozen_string_literal: true class Shoes class Image < Common::UIElement include Common::Clickable include Common::Hover include Common::ImageHandling BINARY_ENCODING = Encoding.find('binary') style_with :art_styles, :common_styles, :dimensions, :file_path STYLES = { fill: Shoes::COLORS[:black] }.freeze def before_initialize(styles, file_path_or_data) styles[:file_path] = normalized_source(file_path_or_data) end def path @style[:file_path] end def path=(path_or_data) style(file_path: normalized_source(path_or_data)) @gui.update_image end def url?(path_or_data) path_or_data =~ %r{^https?://} end def raw_image_data?(name_or_data) name_or_data.encoding == BINARY_ENCODING end private def normalized_source(path_or_data) return path_or_data if raw_image_data?(path_or_data) return path_or_data if url?(path_or_data) absolute_file_path(path_or_data) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
shoes-core-4.0.0.pre12 | lib/shoes/image.rb |
shoes-core-4.0.0.pre11 | lib/shoes/image.rb |
shoes-core-4.0.0.pre10 | lib/shoes/image.rb |