Class: ICuke::Simulate::Gestures::Swipe
- Inherits:
-
Object
- Object
- ICuke::Simulate::Gestures::Swipe
- Defined in:
- lib/icuke/simulate.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#hold_for ⇒ Object
Returns the value of attribute hold_for.
-
#options ⇒ Object
Returns the value of attribute options.
-
#x ⇒ Object
Returns the value of attribute x.
-
#x2 ⇒ Object
Returns the value of attribute x2.
-
#y ⇒ Object
Returns the value of attribute y.
-
#y2 ⇒ Object
Returns the value of attribute y2.
Instance Method Summary collapse
-
#initialize(x, y, x2, y2, hold_for, options) ⇒ Swipe
constructor
A new instance of Swipe.
- #to_json(*a) ⇒ Object
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 = @x = x @y = y @x2 = x2 @y2 = y2 @hold_for = hold_for end |
Instance Attribute Details
#hold_for ⇒ Object
Returns the value of attribute hold_for.
96 97 98 |
# File 'lib/icuke/simulate.rb', line 96 def hold_for @hold_for end |
#options ⇒ Object
Returns the value of attribute options.
96 97 98 |
# File 'lib/icuke/simulate.rb', line 96 def @options end |
#x ⇒ Object
Returns the value of attribute x.
96 97 98 |
# File 'lib/icuke/simulate.rb', line 96 def x @x end |
#x2 ⇒ Object
Returns the value of attribute x2.
96 97 98 |
# File 'lib/icuke/simulate.rb', line 96 def x2 @x2 end |
#y ⇒ Object
Returns the value of attribute y.
96 97 98 |
# File 'lib/icuke/simulate.rb', line 96 def y @y end |
#y2 ⇒ Object
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]], .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 |