Class: Origami::Rectangle

Inherits:
Array show all
Defined in:
lib/origami/array.rb

Overview

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

Constant Summary

Constants inherited from Array

Array::TOKENS

Constants included from Object

Object::TOKENS

Instance Attribute Summary

Attributes inherited from Array

#names_cache, #strings_cache, #xref_cache

Attributes included from Object

#file_offset, #generation, #no, #objstm_offset, #parent

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Array

#+, #<<, #[]=, parse, #pre_build, #real_type, #to_a, #to_obfuscated_str, #to_s

Methods included from Object

#<=>, #copy, #indirect_parent, #is_indirect?, parse, #pdf, #pdf_version_required, #post_build, #pre_build, #reference, #set_indirect, #set_pdf, #size, skip_until_next_obj, #solve, #to_o, #to_s, #type, typeof, #xrefs

Methods inherited from Array

#shuffle, #shuffle!, #to_o

Constructor Details

#initialize(lowerleftx, lowerlefty, upperrightx, upperrighty) ⇒ Rectangle

Returns a new instance of Rectangle.



181
182
183
# File 'lib/origami/array.rb', line 181

def initialize(lowerleftx, lowerlefty, upperrightx, upperrighty)
  super([ lowerleftx, lowerlefty, upperrightx, upperrighty ])
end

Class Method Details

.[](coords) ⇒ Object



169
170
171
172
173
174
175
176
177
# File 'lib/origami/array.rb', line 169

def [](coords)
  corners = coords.values_at(:llx, :lly, :urx, :ury)
  
  unless corners.all? { |corner| corner.is_a?(Numeric) }
    raise TypeError, "All coords must be numbers"
  end
  
  Rectangle.new(*corners)
end