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?
Constructor Details
#initialize(image) ⇒ Datastream
Returns a new instance of Datastream.
49
50
51
52
53
54
55
56
57
|
# File 'lib/applitools/core/screenshot.rb', line 49
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.
47
48
49
|
# File 'lib/applitools/core/screenshot.rb', line 47
def datastream
@datastream
end
|
Instance Method Details
#__getobj__ ⇒ Object
Also known as:
image
74
75
76
|
# File 'lib/applitools/core/screenshot.rb', line 74
def __getobj__
restore
end
|
#__setobj__(obj) ⇒ Object
80
81
82
83
|
# File 'lib/applitools/core/screenshot.rb', line 80
def __setobj__(obj)
@datastream = obj.to_datastream
self
end
|
70
71
72
|
# File 'lib/applitools/core/screenshot.rb', line 70
def
@datastream.
end
|
#restore ⇒ Object
85
86
87
|
# File 'lib/applitools/core/screenshot.rb', line 85
def restore
::ChunkyPNG::Image.from_datastream @datastream
end
|
#to_blob ⇒ Object
66
67
68
|
# File 'lib/applitools/core/screenshot.rb', line 66
def to_blob
@datastream.to_blob
end
|
#update!(image) ⇒ Object
59
60
61
62
63
64
|
# File 'lib/applitools/core/screenshot.rb', line 59
def update!(image)
Applitools::ArgumentGuard.not_nil(image, 'image')
Applitools::ArgumentGuard.is_a?(image, 'image', ::ChunkyPNG::Image)
@datastream = image.to_datastream
self
end
|