Class: Applitools::Screenshot::Datastream
Instance Attribute Summary collapse
Instance Method Summary
collapse
from_any_image, from_datastream, from_image, from_region, #method_missing, #respond_to_missing?, #square
Constructor Details
#initialize(image) ⇒ Datastream
Returns a new instance of Datastream.
55
56
57
58
59
60
61
62
63
|
# File 'lib/applitools/core/screenshot.rb', line 55
def initialize(image)
Applitools::ArgumentGuard.not_nil(image, 'image')
unless image.is_a?(String)
Applitools::ArgumentGuard.raise_argument_error(
"Expected image to be Datastream or String, but got #{image.class}"
)
end
@datastream = ::ChunkyPNG::Datastream.from_string image
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Applitools::Screenshot
Instance Attribute Details
#datastream ⇒ Object
Returns the value of attribute datastream.
53
54
55
|
# File 'lib/applitools/core/screenshot.rb', line 53
def datastream
@datastream
end
|
Instance Method Details
#__getobj__ ⇒ Object
Also known as:
image
80
81
82
|
# File 'lib/applitools/core/screenshot.rb', line 80
def __getobj__
restore
end
|
#__setobj__(obj) ⇒ Object
86
87
88
89
|
# File 'lib/applitools/core/screenshot.rb', line 86
def __setobj__(obj)
@datastream = obj.to_datastream
self
end
|
76
77
78
|
# File 'lib/applitools/core/screenshot.rb', line 76
def
@datastream.
end
|
#restore ⇒ Object
91
92
93
|
# File 'lib/applitools/core/screenshot.rb', line 91
def restore
::ChunkyPNG::Image.from_datastream @datastream
end
|
#to_blob ⇒ Object
72
73
74
|
# File 'lib/applitools/core/screenshot.rb', line 72
def to_blob
@datastream.to_blob
end
|
#update!(image) ⇒ Object
65
66
67
68
69
70
|
# File 'lib/applitools/core/screenshot.rb', line 65
def update!(image)
Applitools::ArgumentGuard.not_nil(image, 'image')
Applitools::ArgumentGuard.is_a?(image, 'image', ::ChunkyPNG::Image)
@datastream = image.to_datastream
self
end
|