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.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/ffi-tk/geometry.rb', line 3 def initialize(tcl_string) case tcl_string.to_s when /^\=?(?<width>\d+)x(?<height>\d+)(?<x>[+-]\d+)(?<y>[+-]\d+)$/ md = $~ self.width, self.height, self.x, self.y = md[:width].to_i, md[:height].to_i, md[:x].to_i, md[:y].to_i when /^\=?(?<width>\d+)x(?<height>\d+)$/ md = $~ self.width, self.height = md[:width].to_i, md[:height].to_i when /^\=?(?<x>[+-]\d+)(?<y>[+-]\d+)$/ md = $~ self.x, self.y = md[:x].to_i, md[:y].to_i else raise "Invalid geometry: %p" % [tcl_string] end end |
Instance Attribute Details
#height ⇒ Object
Returns the value of attribute height
2 3 4 |
# File 'lib/ffi-tk/geometry.rb', line 2 def height @height end |
#original ⇒ Object
Returns the value of attribute original
2 3 4 |
# File 'lib/ffi-tk/geometry.rb', line 2 def original @original end |
#width ⇒ Object
Returns the value of attribute width
2 3 4 |
# File 'lib/ffi-tk/geometry.rb', line 2 def width @width end |
#x ⇒ Object
Returns the value of attribute x
2 3 4 |
# File 'lib/ffi-tk/geometry.rb', line 2 def x @x end |
#y ⇒ Object
Returns the value of attribute y
2 3 4 |
# File 'lib/ffi-tk/geometry.rb', line 2 def y @y end |
Instance Method Details
#to_tcl ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ffi-tk/geometry.rb', line 20 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 |