Class: Frank::Cucumber::Rect
- Inherits:
-
Object
- Object
- Frank::Cucumber::Rect
- Defined in:
- lib/frank-cucumber/rect.rb
Instance Attribute Summary collapse
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Class Method Summary collapse
Instance Method Summary collapse
- #center ⇒ Object
-
#initialize(x, y, width, height) ⇒ Rect
constructor
A new instance of Rect.
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
#height ⇒ Object (readonly)
Returns the value of attribute height.
6 7 8 |
# File 'lib/frank-cucumber/rect.rb', line 6 def height @height end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
6 7 8 |
# File 'lib/frank-cucumber/rect.rb', line 6 def width @width end |
#x ⇒ Object (readonly)
Returns the value of attribute x.
6 7 8 |
# File 'lib/frank-cucumber/rect.rb', line 6 def x @x end |
#y ⇒ Object (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
#center ⇒ Object
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 |