Module: Inlay::Normalizer
- Defined in:
- lib/inlay/normalizer.rb
Constant Summary collapse
- IMAGE_EXTENSIONS =
%w[.png .ppm .pnm .bmp].freeze
Class Method Summary collapse
Class Method Details
.call(object, allow_path: false, seen: {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/inlay/normalizer.rb', line 9 def call(object, allow_path: false, seen: {}) raise Error, "recursive to_inlay result" if seen[object.object_id] converted = Adapters.convert(object) return Normalized.new(image: converted) if converted.is_a?(Tessel::Image) return from_value(converted, allow_path: allow_path, seen: seen) unless converted.nil? return from_value(object.to_inlay, allow_path: allow_path, seen: seen.merge(object.object_id => true)) if object.respond_to?(:to_inlay) return from_value(object, allow_path: allow_path, seen: seen) if object.is_a?(Hash) return from_path(object) if allow_path && path_value?(object) Normalized.new end |
.terminal_image(normalized) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/inlay/normalizer.rb', line 23 def terminal_image(normalized) return normalized.image if normalized.image return Tessel.decode(normalized.png, max_pixels: Inlay.config.max_pixels) if normalized.png.is_a?(String) if normalized.png.respond_to?(:call) value = normalized.png.call return value if value.is_a?(Tessel::Image) return Tessel.decode(value, max_pixels: Inlay.config.max_pixels) if value.is_a?(String) return call(value).image end return call(normalized.frames.first).image if normalized.frames&.any? nil end |