Methods

Class/Module Index [+]

Quicksearch

Origami::Rectangle

Class representing a location on a page or a bounding box.

Public Class Methods

[](coords) click to toggle source
# File lib/origami/array.rb, line 182
def [](coords)
  corners = 
    if [ :llx, :lly, :urx, :ury ].all? {|p| coords.include?(p)}
      coords.values_at(:llx, :lly, :urx, :ury)
    elsif [ :width, :height ].all? {|p| coords.include?(p)}
      width, height = coords.values_at(:width, :height)
      x = coords.values_at(:x).first || 0
      y = coords.values_at(:y).first || 0
      [ x, y, x+width, y+height ]
    else
      raise ArgumentError, "Bad arguments for #{self.class}: #{coords.inspect}"
    end
  
  unless corners.all? { |corner| corner.is_a?(Numeric) }
    raise TypeError, "All coords must be numbers"
  end
  
  Rectangle.new(*corners)
end
new(lowerleftx, lowerlefty, upperrightx, upperrighty) click to toggle source
# File lib/origami/array.rb, line 204
def initialize(lowerleftx, lowerlefty, upperrightx, upperrighty)
  super([ lowerleftx, lowerlefty, upperrightx, upperrighty ])
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.