Class: Applitools::Screenshot

Inherits:
Delegator
  • Object
show all
Defined in:
lib/applitools/core/screenshot.rb

Direct Known Subclasses

Datastream, Image

Defined Under Namespace

Classes: Datastream, Image

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_image) ⇒ Screenshot

Returns a new instance of Screenshot.



27
28
29
# File 'lib/applitools/core/screenshot.rb', line 27

def initialize(_image)
  raise Applitools::EyesError.new 'Applitools::Screenshot is an abstract class!'
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/applitools/core/screenshot.rb', line 35

def method_missing(method, *args, &block)
  if method =~ /^.+!$/
    __setobj__ super
  else
    super
  end
end

Class Method Details

.from_any_image(image) ⇒ Object



19
20
21
22
23
24
# File 'lib/applitools/core/screenshot.rb', line 19

def from_any_image(image)
  return from_region(image) if image.is_a? Applitools::Region
  # return from_image(image) if image.is_a? ::ChunkyPNG::Image
  return image if image.is_a?(Image) | image.is_a?(Datastream)
  from_datastream(image)
end

.from_datastream(datastream) ⇒ Object



11
12
13
# File 'lib/applitools/core/screenshot.rb', line 11

def from_datastream(datastream)
  self::Datastream.new(datastream)
end

.from_image(image) ⇒ Object



15
16
17
# File 'lib/applitools/core/screenshot.rb', line 15

def from_image(image)
  Image.new(image)
end

.from_region(region) ⇒ Object



7
8
9
# File 'lib/applitools/core/screenshot.rb', line 7

def from_region(region)
  # self::Image.new(::ChunkyPNG::Image.new(region.width, region.height))
end

Instance Method Details

#__getobj__Object



31
32
33
# File 'lib/applitools/core/screenshot.rb', line 31

def __getobj__
  nil
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/applitools/core/screenshot.rb', line 43

def respond_to_missing?(method_name, include_private = false)
  super
end

#squareObject



47
48
49
# File 'lib/applitools/core/screenshot.rb', line 47

def square
  width * height
end