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.



37
38
39
# File 'lib/arrolio/flowable.rb', line 37

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

Instance Attribute Details

#styleObject (readonly)

Returns the value of attribute style.



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

def style
  @style
end

Instance Method Details

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



97
98
99
# File 'lib/arrolio/flowable.rb', line 97

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

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

Raises:

  • (NotImplementedError)


45
46
47
# File 'lib/arrolio/flowable.rb', line 45

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

#height(_width, _context = nil) ⇒ Object

Raises:

  • (NotImplementedError)


41
42
43
# File 'lib/arrolio/flowable.rb', line 41

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

#keep_together?Boolean

Returns:

  • (Boolean)


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

def keep_together?
  @style.keep_together
end

#keep_with_next?Boolean

Returns:

  • (Boolean)


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

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.



64
65
66
# File 'lib/arrolio/flowable.rb', line 64

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

#page_break_after?Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/arrolio/flowable.rb', line 72

def page_break_after?
  @style.page_break_after
end

#page_break_before?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/arrolio/flowable.rb', line 68

def page_break_before?
  @style.page_break_before
end

#space_afterObject



80
81
82
# File 'lib/arrolio/flowable.rb', line 80

def space_after
  @style.margin_bottom
end

#space_beforeObject



76
77
78
# File 'lib/arrolio/flowable.rb', line 76

def space_before
  @style.margin_top
end

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



84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/arrolio/flowable.rb', line 84

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)


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

def splittable?
  false
end