Class: Unmagic::Browser::Console::Image
- Defined in:
- lib/unmagic/browser/console/values.rb
Overview
Image bytes the renderer should draw in the terminal.
Instance Attribute Summary
Attributes inherited from Tagged
Instance Method Summary collapse
-
#dimensions ⇒ Array(Integer, Integer)?
The image's pixel size, read straight out of the PNG header — the IHDR chunk is always the first one, at a fixed offset.
-
#extension ⇒ String
The file extension for the copy written to disk.
-
#initialize(value, name: "screenshot") ⇒ Image
constructor
A new instance of Image.
Constructor Details
#initialize(value, name: "screenshot") ⇒ Image
Returns a new instance of Image.
43 44 45 |
# File 'lib/unmagic/browser/console/values.rb', line 43 def initialize(value, name: "screenshot") super(value, name: name) end |
Instance Method Details
#dimensions ⇒ Array(Integer, Integer)?
The image's pixel size, read straight out of the PNG header — the IHDR chunk is always the first one, at a fixed offset.
51 52 53 54 55 |
# File 'lib/unmagic/browser/console/values.rb', line 51 def dimensions return nil unless start_with?("\x89PNG\r\n\x1A\n".b) byteslice(16, 8)&.unpack("N2") end |
#extension ⇒ String
Returns the file extension for the copy written to disk.
58 59 60 |
# File 'lib/unmagic/browser/console/values.rb', line 58 def extension "png" end |