class Magick::Geometry
def initialize(width=nil, height=nil, x=nil, y=nil, flag=nil)
def initialize(width=nil, height=nil, x=nil, y=nil, flag=nil) # Support floating-point width and height arguments so Geometry # objects can be used to specify Image#density= arguments. if width == nil @width = 0 elsif width.to_f >= 0.0 @width = width.to_f else Kernel.raise ArgumentError, "width must be >= 0: #{width}" end if height == nil @height = 0 elsif height.to_f >= 0.0 @height = height.to_f else Kernel.raise ArgumentError, "height must be >= 0: #{height}" end @x = x.to_i @y = y.to_i @flag = flag end
def to_s
def to_s str = '' str << sprintf("%d", @width+0.5) if @width > 0 str << 'x' if (@width > 0 || @height > 0) str << sprintf("%d", @height+0.5) if @height > 0 str << sprintf("%+d%+d", @x+0.5, @y+0.5) if (@x != 0 || @y != 0) str << FLAGS[@flag.to_i] end