Class: Pdf::Builders::ContentBuilder
- Inherits:
-
Object
- Object
- Pdf::Builders::ContentBuilder
show all
- Includes:
- DynamicComponents
- Defined in:
- lib/pdf/builders/content_builder.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#alert(source = nil, **options) ⇒ Object
-
#date(value, **options) ⇒ Object
-
#each(source, **options, &block) ⇒ Object
-
#heading(value, **options) ⇒ Object
-
#hr(**options) ⇒ Object
-
#initialize(blueprint = Blueprint.new) ⇒ ContentBuilder
constructor
A new instance of ContentBuilder.
-
#page_break ⇒ Object
-
#page_break_if(threshold:) ⇒ Object
-
#paragraph(value, **options) ⇒ Object
-
#partial(method_name) ⇒ Object
-
#raw(&block) ⇒ Object
Escape hatch for direct Prawn access.
-
#render_if(condition, &block) ⇒ Object
Conditional rendering - render block only if condition is truthy.
-
#render_unless(condition, &block) ⇒ Object
Conditional rendering - render block only if condition is falsy.
-
#section(title_text, **options, &block) ⇒ Object
-
#spacer(**options) ⇒ Object
-
#span(value, **options) ⇒ Object
-
#subtitle(value, **options) ⇒ Object
-
#table(source, **options) ⇒ Object
-
#title(value, **options) ⇒ Object
#method_missing, #respond_to_missing?
Constructor Details
#initialize(blueprint = Blueprint.new) ⇒ ContentBuilder
Returns a new instance of ContentBuilder.
10
11
12
|
# File 'lib/pdf/builders/content_builder.rb', line 10
def initialize(blueprint = Blueprint.new)
@blueprint = blueprint
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Pdf::DynamicComponents
Instance Attribute Details
#blueprint ⇒ Object
Returns the value of attribute blueprint.
8
9
10
|
# File 'lib/pdf/builders/content_builder.rb', line 8
def blueprint
@blueprint
end
|
Instance Method Details
#alert(source = nil, **options) ⇒ Object
46
47
48
|
# File 'lib/pdf/builders/content_builder.rb', line 46
def alert(source = nil, **options)
@blueprint.add(:alert, source, **options)
end
|
#date(value, **options) ⇒ Object
22
23
24
|
# File 'lib/pdf/builders/content_builder.rb', line 22
def date(value, **options)
@blueprint.add(:date, value, **options)
end
|
#each(source, **options, &block) ⇒ Object
60
61
62
|
# File 'lib/pdf/builders/content_builder.rb', line 60
def each(source, **options, &block)
@blueprint.add(:each, source, block: block, **options)
end
|
#heading(value, **options) ⇒ Object
26
27
28
|
# File 'lib/pdf/builders/content_builder.rb', line 26
def heading(value, **options)
@blueprint.add(:heading, value, **options)
end
|
#hr(**options) ⇒ Object
38
39
40
|
# File 'lib/pdf/builders/content_builder.rb', line 38
def hr(**options)
@blueprint.add(:hr, **options)
end
|
#page_break ⇒ Object
68
69
70
|
# File 'lib/pdf/builders/content_builder.rb', line 68
def page_break
@blueprint.add(:page_break)
end
|
#page_break_if(threshold:) ⇒ Object
72
73
74
|
# File 'lib/pdf/builders/content_builder.rb', line 72
def page_break_if(threshold:)
@blueprint.add(:page_break_if, threshold: threshold)
end
|
#paragraph(value, **options) ⇒ Object
30
31
32
|
# File 'lib/pdf/builders/content_builder.rb', line 30
def paragraph(value, **options)
@blueprint.add(:paragraph, value, **options)
end
|
#partial(method_name) ⇒ Object
64
65
66
|
# File 'lib/pdf/builders/content_builder.rb', line 64
def partial(method_name)
@blueprint.add(:partial, method_name)
end
|
#raw(&block) ⇒ Object
Escape hatch for direct Prawn access
91
92
93
|
# File 'lib/pdf/builders/content_builder.rb', line 91
def raw(&block)
@blueprint.add(:raw, block: block)
end
|
#render_if(condition, &block) ⇒ Object
Conditional rendering - render block only if condition is truthy
77
78
79
80
81
|
# File 'lib/pdf/builders/content_builder.rb', line 77
def render_if(condition, &block)
nested = self.class.new
nested.instance_eval(&block) if block
@blueprint.add(:render_if, condition, nested: nested.blueprint)
end
|
#render_unless(condition, &block) ⇒ Object
Conditional rendering - render block only if condition is falsy
84
85
86
87
88
|
# File 'lib/pdf/builders/content_builder.rb', line 84
def render_unless(condition, &block)
nested = self.class.new
nested.instance_eval(&block) if block
@blueprint.add(:render_unless, condition, nested: nested.blueprint)
end
|
#section(title_text, **options, &block) ⇒ Object
54
55
56
57
58
|
# File 'lib/pdf/builders/content_builder.rb', line 54
def section(title_text, **options, &block)
nested = self.class.new
nested.instance_eval(&block) if block
@blueprint.add(:section, title_text, nested: nested.blueprint, **options)
end
|
#spacer(**options) ⇒ Object
42
43
44
|
# File 'lib/pdf/builders/content_builder.rb', line 42
def spacer(**options)
@blueprint.add(:spacer, **options)
end
|
#span(value, **options) ⇒ Object
34
35
36
|
# File 'lib/pdf/builders/content_builder.rb', line 34
def span(value, **options)
@blueprint.add(:span, value, **options)
end
|
#subtitle(value, **options) ⇒ Object
18
19
20
|
# File 'lib/pdf/builders/content_builder.rb', line 18
def subtitle(value, **options)
@blueprint.add(:subtitle, value, **options)
end
|
#table(source, **options) ⇒ Object
50
51
52
|
# File 'lib/pdf/builders/content_builder.rb', line 50
def table(source, **options)
@blueprint.add(:table, source, **options)
end
|
#title(value, **options) ⇒ Object
14
15
16
|
# File 'lib/pdf/builders/content_builder.rb', line 14
def title(value, **options)
@blueprint.add(:title, value, **options)
end
|