Class: Arrolio::Flowables::Spacer

Inherits:
Arrolio::Flowable show all
Defined in:
lib/arrolio/flowables/spacer.rb

Instance Attribute Summary collapse

Attributes inherited from Arrolio::Flowable

#style

Instance Method Summary collapse

Methods inherited from Arrolio::Flowable

#keep_together?, #keep_with_next?, #page_break_after?, #page_break_before?, #space_after, #space_before, #split

Constructor Details

#initialize(amount, style: Style::Definition.new) ⇒ Spacer

Returns a new instance of Spacer.



8
9
10
11
# File 'lib/arrolio/flowables/spacer.rb', line 8

def initialize(amount, style: Style::Definition.new)
  super(style: style)
  @amount = amount.to_f
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



6
7
8
# File 'lib/arrolio/flowables/spacer.rb', line 6

def amount
  @amount
end

Instance Method Details

#do_split(_width, remaining_height, _context = nil) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/arrolio/flowables/spacer.rb', line 25

def do_split(_width, remaining_height, _context = nil)
  if @amount <= remaining_height
    [self, nil]
  else
    [self.class.new(remaining_height), self.class.new(@amount - remaining_height)]
  end
end

#emit(_x, _y, _width, _context = nil) ⇒ Object



17
18
19
# File 'lib/arrolio/flowables/spacer.rb', line 17

def emit(_x, _y, _width, _context = nil)
  [[], @amount]
end

#height(_width, _context = nil) ⇒ Object



13
14
15
# File 'lib/arrolio/flowables/spacer.rb', line 13

def height(_width, _context = nil)
  @amount
end

#splittable?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/arrolio/flowables/spacer.rb', line 21

def splittable?
  true
end