Class: ICuke::Simulate::Gestures::Swipe

Inherits:
Object
  • Object
show all
Defined in:
lib/icuke/simulate.rb

Direct Known Subclasses

Drag

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x, y, x2, y2, hold_for, options) ⇒ Swipe

Returns a new instance of Swipe.



98
99
100
101
102
103
104
105
106
# File 'lib/icuke/simulate.rb', line 98

def initialize(x, y, x2, y2, hold_for, options)
  @options = options
  
  @x = x
  @y = y
  @x2 = x2
  @y2 = y2
  @hold_for = hold_for
end

Instance Attribute Details

#hold_forObject

Returns the value of attribute hold_for.



96
97
98
# File 'lib/icuke/simulate.rb', line 96

def hold_for
  @hold_for
end

#optionsObject

Returns the value of attribute options.



96
97
98
# File 'lib/icuke/simulate.rb', line 96

def options
  @options
end

#xObject

Returns the value of attribute x.



96
97
98
# File 'lib/icuke/simulate.rb', line 96

def x
  @x
end

#x2Object

Returns the value of attribute x2.



96
97
98
# File 'lib/icuke/simulate.rb', line 96

def x2
  @x2
end

#yObject

Returns the value of attribute y.



96
97
98
# File 'lib/icuke/simulate.rb', line 96

def y
  @y
end

#y2Object

Returns the value of attribute y2.



96
97
98
# File 'lib/icuke/simulate.rb', line 96

def y2
  @y2
end

Instance Method Details

#to_json(*a) ⇒ Object



108
109
110
111
112
113
114
115
# File 'lib/icuke/simulate.rb', line 108

def to_json(*a)
  events = [ICuke::Simulate::Events::Touch.new(:down, [[x, y]], options.merge(:hold_for => hold_for))]
  each_point([x, y], [x2, y2], 25) do |ix, iy|
    events << ICuke::Simulate::Events::Touch.new(:moved, [[ix, iy]], :hold_for => hold_for)
  end
  events << ICuke::Simulate::Events::Touch.new(:up, [[x2, y2]], :hold_for => hold_for)
  events.to_json(*a)
end