Class: Wx::Size
- Inherits:
-
Object
- Object
- Wx::Size
- Defined in:
- lib/wx/classes/size.rb
Instance Method Summary collapse
-
#*(mul) ⇒ Object
Return a new Wx::Size with the width and height values both multiplied by parameter
mul
, which should be a Numeric. -
#+(arg) ⇒ Object
Return a new Wx::Size with the width and height parameters both increased by parameter
arg
. -
#-(arg) ⇒ Object
Return a new Wx::Size with the width and height parameters both reduced by parameter
arg
. -
#/(div) ⇒ Object
Return a new Wx::Size with the width and height values both divided by parameter
div
, which should be a Numeric. -
#==(other) ⇒ Object
Compare with another size.
-
#to_s ⇒ Object
More informative output for inspect etc.
Instance Method Details
#*(mul) ⇒ Object
Return a new Wx::Size with the width and height values both multiplied by parameter mul
, which should be a Numeric
23 24 25 |
# File 'lib/wx/classes/size.rb', line 23 def *(mul) self.class.new( (get_x * mul).to_i, (get_y * mul).to_i ) end |
#+(arg) ⇒ Object
Return a new Wx::Size with the width and height parameters both increased by parameter arg
. If arg
is another Wx::Size, increase width by the other’s width and height by the other’s height; if arg
is a numeric value, increase both width and height by that value.
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/wx/classes/size.rb', line 48 def +(arg) case arg when self.class self.class.new( get_x + arg.get_x, get_y + arg.get_y ) when Numeric self.class.new( (get_x + arg).to_i, (get_y + arg).to_i ) else Kernel.raise TypeError, "Cannot add #{arg} to #{self.inspect}" end end |
#-(arg) ⇒ Object
Return a new Wx::Size with the width and height parameters both reduced by parameter arg
. If arg
is another Wx::Size, reduce width by the other’s width and height by the other’s height; if arg
is a numeric value, reduce both width and height by that value.
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/wx/classes/size.rb', line 32 def -(arg) case arg when self.class self.class.new( get_x - arg.get_x, get_y - arg.get_y ) when Numeric self.class.new( (get_x - arg).to_i, (get_y - arg).to_i ) else Kernel.raise TypeError, "Cannot add #{arg} to #{self.inspect}" end end |
#/(div) ⇒ Object
Return a new Wx::Size with the width and height values both divided by parameter div
, which should be a Numeric
17 18 19 |
# File 'lib/wx/classes/size.rb', line 17 def /(div) self.class.new( (get_x / div).to_i, (get_y / div).to_i ) end |
#==(other) ⇒ Object
Compare with another size
8 9 10 11 12 13 |
# File 'lib/wx/classes/size.rb', line 8 def ==(other) unless other.kind_of?(Wx::Size) Kernel.raise TypeError, "Cannot compare Size to #{other}" end get_x == other.get_x and get_y == other.get_y end |
#to_s ⇒ Object
More informative output for inspect etc
3 4 5 |
# File 'lib/wx/classes/size.rb', line 3 def to_s "#<Wx::Size: (#{get_width}, #{get_height})>" end |