Class: Frank::Cucumber::Rect

Inherits:
Object
  • Object
show all
Defined in:
lib/frank-cucumber/rect.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x, y, width, height) ⇒ Rect

Returns a new instance of Rect.



14
15
16
# File 'lib/frank-cucumber/rect.rb', line 14

def initialize(x,y,width,height)
  @x,@y,@width,@height = x,y,width,height
end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



6
7
8
# File 'lib/frank-cucumber/rect.rb', line 6

def height
  @height
end

#widthObject (readonly)

Returns the value of attribute width.



6
7
8
# File 'lib/frank-cucumber/rect.rb', line 6

def width
  @width
end

#xObject (readonly)

Returns the value of attribute x.



6
7
8
# File 'lib/frank-cucumber/rect.rb', line 6

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



6
7
8
# File 'lib/frank-cucumber/rect.rb', line 6

def y
  @y
end

Class Method Details

.from_api_repr(hash) ⇒ Object



8
9
10
11
12
# File 'lib/frank-cucumber/rect.rb', line 8

def self.from_api_repr( hash )
  x,y = hash["origin"]["x"], hash["origin"]["y"]
  width,height = hash["size"]["width"],hash["size"]["height"]
  self.new( x, y, width, height )
end

Instance Method Details

#centerObject



18
19
20
21
22
23
# File 'lib/frank-cucumber/rect.rb', line 18

def center
  OpenStruct.new( 
                 :x => @x.to_f + (@width.to_f/2),
                 :y => @y.to_f + (@height.to_f/2)
                )
end