Class: MuPDF::Box
- Inherits:
-
Object
- Object
- MuPDF::Box
- Defined in:
- lib/mupdf/box.rb
Overview
A bounding box for a PDF (e.g. media / crop / bleed / trim).
Constant Summary collapse
- REGEX =
/l="(?<l>\d+)" b="(?<b>\d+)" r="(?<r>\d+)" t="(?<t>\d+)"/
Instance Attribute Summary collapse
-
#b ⇒ Object
Returns the value of attribute b.
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#l ⇒ Object
Returns the value of attribute l.
-
#r ⇒ Object
Returns the value of attribute r.
-
#t ⇒ Object
Returns the value of attribute t.
Class Method Summary collapse
Instance Method Summary collapse
- #height ⇒ Integer
-
#initialize(l:, b:, r:, t:, kind: nil) ⇒ Box
constructor
A new instance of Box.
- #inspect ⇒ String
- #width ⇒ Integer
Constructor Details
#initialize(l:, b:, r:, t:, kind: nil) ⇒ Box
Returns a new instance of Box.
49 50 51 52 53 54 55 |
# File 'lib/mupdf/box.rb', line 49 def initialize(l:, b:, r:, t:, kind: nil) @l = l @b = b @r = r @t = t @kind = kind end |
Instance Attribute Details
#b ⇒ Object
Returns the value of attribute b.
14 15 16 |
# File 'lib/mupdf/box.rb', line 14 def b @b end |
#kind ⇒ Object
Returns the value of attribute kind.
26 27 28 |
# File 'lib/mupdf/box.rb', line 26 def kind @kind end |
#l ⇒ Object
Returns the value of attribute l.
10 11 12 |
# File 'lib/mupdf/box.rb', line 10 def l @l end |
#r ⇒ Object
Returns the value of attribute r.
18 19 20 |
# File 'lib/mupdf/box.rb', line 18 def r @r end |
#t ⇒ Object
Returns the value of attribute t.
22 23 24 |
# File 'lib/mupdf/box.rb', line 22 def t @t end |
Class Method Details
.parse(text, kind:) ⇒ MuPDF::Box
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/mupdf/box.rb', line 32 def self.parse(text, kind:) match = text.match(REGEX) new( l: Integer(match[:l]), b: Integer(match[:b]), r: Integer(match[:r]), t: Integer(match[:t]), kind: ) end |
Instance Method Details
#height ⇒ Integer
68 69 70 |
# File 'lib/mupdf/box.rb', line 68 def height @t - @b end |
#inspect ⇒ String
58 59 60 |
# File 'lib/mupdf/box.rb', line 58 def inspect "#<#{self.class.name} l=#{l} b=#{b} r=#{r} t=#{t} kind=#{kind}>" end |
#width ⇒ Integer
63 64 65 |
# File 'lib/mupdf/box.rb', line 63 def width @r - @l end |