Class: ChupaText::Screenshot
- Inherits:
-
Object
- Object
- ChupaText::Screenshot
- Defined in:
- lib/chupa-text/screenshot.rb
Instance Attribute Summary collapse
-
#data ⇒ String
readonly
The data of the screenshot.
-
#encoding ⇒ String?
readonly
The encoding of the screenshot data.
-
#mime_type ⇒ String
readonly
The MIME type of the screenshot.
Instance Method Summary collapse
- #decoded_data ⇒ Object
-
#initialize(mime_type, data, encoding = nil) ⇒ Screenshot
constructor
A new instance of Screenshot.
Constructor Details
#initialize(mime_type, data, encoding = nil) ⇒ Screenshot
Returns a new instance of Screenshot.
31 32 33 34 35 |
# File 'lib/chupa-text/screenshot.rb', line 31 def initialize(mime_type, data, encoding=nil) @mime_type = mime_type @data = data @encoding = encoding end |
Instance Attribute Details
#data ⇒ String (readonly)
Returns The data of the screenshot.
23 24 25 |
# File 'lib/chupa-text/screenshot.rb', line 23 def data @data end |
#encoding ⇒ String? (readonly)
Returns The encoding of the screenshot data.
nil
means that the data is raw data. It's used for SVG data
because it's text data. "base64"
means that the data is encoded
by Base64. It's used for PNG data because it's binary data.
29 30 31 |
# File 'lib/chupa-text/screenshot.rb', line 29 def encoding @encoding end |
#mime_type ⇒ String (readonly)
Returns The MIME type of the screenshot.
20 21 22 |
# File 'lib/chupa-text/screenshot.rb', line 20 def mime_type @mime_type end |
Instance Method Details
#decoded_data ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/chupa-text/screenshot.rb', line 37 def decoded_data case @encoding when "base64" @data.unpack("m*")[0] else @data end end |