Class: Tk::TkGeometry
Instance Attribute Summary collapse
-
#height ⇒ Object
Returns the value of attribute height.
-
#original ⇒ Object
Returns the value of attribute original.
-
#width ⇒ Object
Returns the value of attribute width.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
-
#initialize(tcl_string) ⇒ TkGeometry
constructor
A new instance of TkGeometry.
- #to_tcl ⇒ Object
Constructor Details
#initialize(tcl_string) ⇒ TkGeometry
Returns a new instance of TkGeometry.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ffi-tk/geometry.rb', line 4 def initialize(tcl_string) str = tcl_string.to_s if /^\=?(?<width>\d+)x(?<height>\d+)(?<x>[+-]\d+)(?<y>[+-]\d+)$/ =~ str self.width = Integer(width) self.height = Integer(height) self.x = Integer(x) self.y = Integer(y) elsif /^\=?(?<width>\d+)x(?<height>\d+)$/ =~ str self.width = Integer(width) self.height = Integer(height) elsif /^\=?(?<x>[+-]\d+)(?<y>[+-]\d+)$/ =~ str self.x = Integer(x) self.y = Integer(y) else raise 'Invalid geometry: %p' % [tcl_string] end end |
Instance Attribute Details
#height ⇒ Object
Returns the value of attribute height
3 4 5 |
# File 'lib/ffi-tk/geometry.rb', line 3 def height @height end |
#original ⇒ Object
Returns the value of attribute original
3 4 5 |
# File 'lib/ffi-tk/geometry.rb', line 3 def original @original end |
#width ⇒ Object
Returns the value of attribute width
3 4 5 |
# File 'lib/ffi-tk/geometry.rb', line 3 def width @width end |
#x ⇒ Object
Returns the value of attribute x
3 4 5 |
# File 'lib/ffi-tk/geometry.rb', line 3 def x @x end |
#y ⇒ Object
Returns the value of attribute y
3 4 5 |
# File 'lib/ffi-tk/geometry.rb', line 3 def y @y end |
Instance Method Details
#to_tcl ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ffi-tk/geometry.rb', line 23 def to_tcl if width && height && x && y '=%dx%d%+d%+d' % [width, height, x, y] elsif width && height '=%dx%d%' % [width, height] elsif x && y '=+d%+d' % [x, y] else raise 'Incomplete geometry: %p' % [self] end end |