module ChunkyPNG
def self.Point(*args)
- See: ChunkyPNG::Point -
Raises:
-
(ArgumentError)
- if the arguments weren't understood.
Returns:
-
(ChunkyPNG::Point)
- -
(ChunkyPNG::Point)
- The instantiated point. -
(ChunkyPNG::Point)
- The instantiated point. -
(ChunkyPNG::Point)
- The instantiated point. -
(ChunkyPNG::Point)
- The instantiated point.
Parameters:
-
string
(String
) -- A string that contains the coordinates, e.g. '0, 4', -
array
(Hash
) -- A hash with the :x or 'x' and :y or -
array
(Array
) -- A two element array which represent the x- and y-coordinate. -
y
(Integer, :to_i
) -- The y-coordinate -
x
(Integer, :to_i
) -- The x-coordinate
Overloads:
-
Point(string)
-
Point(hash)
-
Point(array)
-
Point(x, y)
def self.Point(*args) case args.length when 2; ChunkyPNG::Point.new(*args) when 1; case source = args.first when ChunkyPNG::Point; source when ChunkyPNG::Dimension; ChunkyPNG::Point.new(source.width, source.height) when Array; ChunkyPNG::Point.new(source[0], source[1]) when Hash; ChunkyPNG::Point.new(source[:x] || source['x'], source[:y] || source['y']) when ChunkyPNG::Point::POINT_REGEXP; ChunkyPNG::Point.new($1.to_i, $2.to_i) else if source.respond_to?(:x) && source.respond_to?(:y) ChunkyPNG::Point.new(source.x, source.y) else raise ArgumentError, "Don't know how to construct a point from #{source.inspect}!" end end else raise ArgumentError, "Don't know how to construct a point from #{args.inspect}!" end end