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+.?\d*)" b="(?<b>\d+.?\d*)" r="(?<r>\d+.?\d*)" t="(?<t>\d+.?\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 ⇒ BigDecimal
-
#initialize(l:, b:, r:, t:, kind: nil) ⇒ Box
constructor
A new instance of Box.
- #inspect ⇒ String
- #width ⇒ BigDecimal
Constructor Details
#initialize(l:, b:, r:, t:, kind: nil) ⇒ Box
Returns a new instance of Box.
50 51 52 53 54 55 56 |
# File 'lib/mupdf/box.rb', line 50 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 43 |
# File 'lib/mupdf/box.rb', line 32 def self.parse(text, kind:) match = text.match(REGEX) return unless match new( l: BigDecimal(match[:l]), b: BigDecimal(match[:b]), r: BigDecimal(match[:r]), t: BigDecimal(match[:t]), kind: ) end |
Instance Method Details
#height ⇒ BigDecimal
69 70 71 |
# File 'lib/mupdf/box.rb', line 69 def height @t - @b end |
#inspect ⇒ String
59 60 61 |
# File 'lib/mupdf/box.rb', line 59 def inspect "#<#{self.class.name} l=#{l} b=#{b} r=#{r} t=#{t} kind=#{kind}>" end |
#width ⇒ BigDecimal
64 65 66 |
# File 'lib/mupdf/box.rb', line 64 def width @r - @l end |