Class: Calabash::Android::Gestures::MultiTouchGesture

Inherits:
Object
  • Object
show all
Defined in:
lib/calabash-android/gestures.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gestures = []) ⇒ MultiTouchGesture

Returns a new instance of MultiTouchGesture.



11
12
13
14
15
16
17
18
# File 'lib/calabash-android/gestures.rb', line 11

def initialize(gestures = [])
  unless gestures.is_a?(Array)
    gestures = [gestures]
  end

  @gestures = gestures
  @timeout = Calabash::Android::Defaults.query_timeout
end

Instance Attribute Details

#gesturesObject (readonly)

Returns the value of attribute gestures.



8
9
10
# File 'lib/calabash-android/gestures.rb', line 8

def gestures
  @gestures
end

#timeoutObject

Returns the value of attribute timeout.



9
10
11
# File 'lib/calabash-android/gestures.rb', line 9

def timeout
  @timeout
end

Instance Method Details

#+(gesture_collection) ⇒ Object



20
21
22
# File 'lib/calabash-android/gestures.rb', line 20

def +(gesture_collection)
  MultiTouchGesture.new(@gestures + gesture_collection.gestures)
end

#<<(gesture) ⇒ Object



29
30
31
# File 'lib/calabash-android/gestures.rb', line 29

def <<(gesture)
  @gestures << gesture
end

#add_gestureObject



24
25
26
27
# File 'lib/calabash-android/gestures.rb', line 24

def add_gesture
  gestures = @gestures
  MultiTouchGesture.new(gestures + gesture_collection.gestures)
end

#add_touch(touch, index = 0) ⇒ Object



33
34
35
36
37
# File 'lib/calabash-android/gestures.rb', line 33

def add_touch(touch, index=0)
  gestures = @gestures
  gestures[index] << touch
  MultiTouchGesture.new(gestures)
end

#add_touch!(touch, index = 0) ⇒ Object



39
40
41
# File 'lib/calabash-android/gestures.rb', line 39

def add_touch!(touch, index=0)
  @gestures = add_touch(touch, index).gestures
end

#max_execution_timeObject



70
71
72
# File 'lib/calabash-android/gestures.rb', line 70

def max_execution_time
  (@gestures.map {|gesture| gesture.max_execution_time}).max
end

#merge(multi_touch_gesture) ⇒ Object



43
44
45
# File 'lib/calabash-android/gestures.rb', line 43

def merge(multi_touch_gesture)
  MultiTouchGesture.new(gestures.map.with_index {|gesture, index| gesture + multi_touch_gesture.gestures[index]})
end

#merge!(multi_touch_gesture) ⇒ Object



47
48
49
# File 'lib/calabash-android/gestures.rb', line 47

def merge!(multi_touch_gesture)
  @gestures = merge(multi_touch_gesture).gestures
end

#offset=(offset) ⇒ Object



66
67
68
# File 'lib/calabash-android/gestures.rb', line 66

def offset=(offset)
  @gestures.each {|gesture| gesture.offset=offset}
end

#query_string=(query_string) ⇒ Object



58
59
60
# File 'lib/calabash-android/gestures.rb', line 58

def query_string=(query_string)
  @gestures.each {|gesture| gesture.query_string=query_string}
end

#reset_query_stringObject



62
63
64
# File 'lib/calabash-android/gestures.rb', line 62

def reset_query_string
  @gestures.each {|gesture| gesture.reset_query_string}
end

#to_json(*object) ⇒ Object



51
52
53
54
55
56
# File 'lib/calabash-android/gestures.rb', line 51

def to_json(*object)
  {
      query_timeout: @timeout.to_f,
      gestures: @gestures
  }.to_json(*object)
end