Class: Describer

Inherits:
Object
  • Object
show all
Defined in:
lib/xcmonkey/describer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Describer

Returns a new instance of Describer.



4
5
6
7
8
9
# File 'lib/xcmonkey/describer.rb', line 4

def initialize(params)
  ensure_required_params(params)
  self.x = params[:x]
  self.y = params[:y]
  self.driver = Driver.new(params)
end

Instance Attribute Details

#driverObject

Returns the value of attribute driver.



2
3
4
# File 'lib/xcmonkey/describer.rb', line 2

def driver
  @driver
end

#xObject

Returns the value of attribute x.



2
3
4
# File 'lib/xcmonkey/describer.rb', line 2

def x
  @x
end

#yObject

Returns the value of attribute y.



2
3
4
# File 'lib/xcmonkey/describer.rb', line 2

def y
  @y
end

Instance Method Details

#ensure_required_params(params) ⇒ Object



16
17
18
19
20
# File 'lib/xcmonkey/describer.rb', line 16

def ensure_required_params(params)
  Logger.error('UDID should be provided') if params[:udid].nil?
  Logger.error('`x` point coordinate should be provided') if params[:x].nil? || params[:x].to_i.to_s != params[:x].to_s
  Logger.error('`y` point coordinate should be provided') if params[:y].nil? || params[:y].to_i.to_s != params[:y].to_s
end

#runObject



11
12
13
14
# File 'lib/xcmonkey/describer.rb', line 11

def run
  driver.ensure_device_exists
  driver.describe_point(x, y)
end