class Calabash::Android::Gestures::Touch

Attributes

offset_x[RW]
offset_y[RW]
query_string[RW]
release[RW]
time[RW]
wait[RW]
x[RW]
y[RW]

Public Class Methods

new(touch) click to toggle source
# File lib/calabash-android/gestures.rb, line 242
def initialize(touch)
  if touch.is_a?(Touch)
    touch = touch.to_hash
  end

  touch[:offset] ||= {}
  touch[:offset_x] ||= touch[:offset][:x]
  touch[:offset_y] ||= touch[:offset][:y]

  @x = touch[:x]
  @y = touch[:y]
  @offset_x = touch[:offset_x] || 0
  @offset_y = touch[:offset_y] || 0
  @wait = touch[:wait] || 0
  @time = touch[:time] || 0
  @release = touch[:release].nil? ? false : touch[:release]
  @query_string = touch[:query_string]
end

Public Instance Methods

+(touch) click to toggle source
# File lib/calabash-android/gestures.rb, line 282
def +(touch)
  hash = to_hash
  hash[:x] += touch.x
  hash[:y] += touch.y
  hash[:offset_x] += touch.offset_x
  hash[:offset_y] += touch.offset_y
  Touch.new(hash)
end
-(touch) click to toggle source
# File lib/calabash-android/gestures.rb, line 291
def -(touch)
  hash = to_hash
  hash[:x] -= touch.x
  hash[:y] -= touch.y
  hash[:offset_x] -= touch.offset_x
  hash[:offset_y] -= touch.offset_y
  Touch.new(hash)
end
merge(touch) click to toggle source
# File lib/calabash-android/gestures.rb, line 261
def merge(touch)
  Touch.new(to_hash.merge(touch.to_hash))
end
offset=(offset) click to toggle source
# File lib/calabash-android/gestures.rb, line 300
def offset=(offset)
  @offset_x = offset[:x]
  @offset_y = offset[:y]
end
to_hash() click to toggle source
# File lib/calabash-android/gestures.rb, line 265
def to_hash
  {
      x: @x,
      y: @y,
      offset_x: @offset_x || 0,
      offset_y: @offset_y || 0,
      wait: @wait.to_f,
      time: @time.to_f,
      release: @release,
      query_string: @query_string
  }
end
to_json(object = Hash) click to toggle source
# File lib/calabash-android/gestures.rb, line 278
def to_json(object = Hash)
  to_hash.to_json(object)
end