Class: Arrolio::Flowable

Inherits:
Object
  • Object
show all
Defined in:
lib/arrolio/flowable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(style: Style::Definition.new) ⇒ Flowable

Returns a new instance of Flowable.



23
24
25
# File 'lib/arrolio/flowable.rb', line 23

def initialize(style: Style::Definition.new)
  @style = style
end

Instance Attribute Details

#styleObject (readonly)

Returns the value of attribute style.



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

def style
  @style
end

Instance Method Details

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



83
84
85
# File 'lib/arrolio/flowable.rb', line 83

def do_split(_width, _remaining_height, _context = nil)
  [self, nil]
end

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

Raises:

  • (NotImplementedError)


31
32
33
# File 'lib/arrolio/flowable.rb', line 31

def emit(_x, _y, _width, _context = nil)
  raise NotImplementedError, "#{self.class}#emit not implemented"
end

#height(_width, _context = nil) ⇒ Object

Raises:

  • (NotImplementedError)


27
28
29
# File 'lib/arrolio/flowable.rb', line 27

def height(_width, _context = nil)
  raise NotImplementedError, "#{self.class}#height not implemented"
end

#keep_together?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/arrolio/flowable.rb', line 39

def keep_together?
  @style.keep_together
end

#keep_with_next?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/arrolio/flowable.rb', line 43

def keep_with_next?
  @style.keep_with_next
end

#min_keep_height(width, context = nil) ⇒ Object

Height that must stay on the same page as a preceding keep-with-next flowable: the whole flowable when atomic, the first line (plus space-before) when splittable.



50
51
52
# File 'lib/arrolio/flowable.rb', line 50

def min_keep_height(width, context = nil)
  height(width, context)
end

#page_break_after?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/arrolio/flowable.rb', line 58

def page_break_after?
  @style.page_break_after
end

#page_break_before?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/arrolio/flowable.rb', line 54

def page_break_before?
  @style.page_break_before
end

#space_afterObject



66
67
68
# File 'lib/arrolio/flowable.rb', line 66

def space_after
  @style.margin_bottom
end

#space_beforeObject



62
63
64
# File 'lib/arrolio/flowable.rb', line 62

def space_before
  @style.margin_top
end

#split(width, remaining_height, context = nil) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/arrolio/flowable.rb', line 70

def split(width, remaining_height, context = nil)
  natural = height(width, context)
  if natural <= remaining_height
    [self, nil]
  elsif splittable?
    do_split(width, remaining_height, context)
  elsif keep_together?
    [nil, self]
  else
    [self, nil]
  end
end

#splittable?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/arrolio/flowable.rb', line 35

def splittable?
  false
end