Class: Repubmark::Elems::Canvas
- Inherits:
-
Base
- Object
- Base
- Repubmark::Elems::Canvas
show all
- Defined in:
- lib/repubmark/elems/canvas.rb
Instance Attribute Summary
Attributes inherited from Base
#parent
Instance Method Summary
collapse
Methods inherited from Base
#absolute_url, #config, #count_words, #html_class, #own_url, parent?, parents, #relative_url
Constructor Details
#initialize(parent) ⇒ Canvas
Returns a new instance of Canvas.
8
9
10
11
|
# File 'lib/repubmark/elems/canvas.rb', line 8
def initialize(parent)
super parent
@items = []
end
|
Instance Method Details
#blockquote {|blockquote| ... } ⇒ Object
37
38
39
40
41
42
|
# File 'lib/repubmark/elems/canvas.rb', line 37
def blockquote
blockquote = Blockquote.new self
@items << blockquote
yield blockquote
nil
end
|
#code_block(*args, **kwargs) ⇒ Object
44
45
46
47
48
|
# File 'lib/repubmark/elems/canvas.rb', line 44
def code_block(*args, **kwargs)
code_block = CodeBlock.new self, *args, **kwargs
@items << code_block
nil
end
|
#iframe(*args, **kwargs) ⇒ Object
50
51
52
53
54
|
# File 'lib/repubmark/elems/canvas.rb', line 50
def iframe(*args, **kwargs)
iframe = Iframe.new self, *args, **kwargs
@items << iframe
nil
end
|
#links_list {|list| ... } ⇒ Object
56
57
58
59
60
61
|
# File 'lib/repubmark/elems/canvas.rb', line 56
def links_list
list = List.new self, links: true, ordered: false
@items << list
yield list
nil
end
|
63
64
65
66
67
68
|
# File 'lib/repubmark/elems/canvas.rb', line 63
def nice_figure(name, alt)
figure = Figure.new self, name, alt
@items << figure
yield figure if block_given?
nil
end
|
70
71
72
73
74
75
|
# File 'lib/repubmark/elems/canvas.rb', line 70
def nice_figures
figures = Figures.new self
@items << figures
yield figures
nil
end
|
#olist {|list| ... } ⇒ Object
77
78
79
80
81
82
|
# File 'lib/repubmark/elems/canvas.rb', line 77
def olist
list = List.new self, links: false, ordered: true
@items << list
yield list
nil
end
|
#paragraph {|paragraph| ... } ⇒ Object
84
85
86
87
88
89
|
# File 'lib/repubmark/elems/canvas.rb', line 84
def paragraph
paragraph = Paragraph.new self
@items << paragraph
yield paragraph
nil
end
|
#separator ⇒ Object
91
92
93
94
|
# File 'lib/repubmark/elems/canvas.rb', line 91
def separator
@items << Separator.new(self)
nil
end
|
#to_gemtext ⇒ Object
29
30
31
|
# File 'lib/repubmark/elems/canvas.rb', line 29
def to_gemtext
@items.map(&:to_gemtext).join("\n").freeze unless @items.empty?
end
|
#to_html ⇒ Object
25
26
27
|
# File 'lib/repubmark/elems/canvas.rb', line 25
def to_html
@items.map(&:to_html).join.freeze unless @items.empty?
end
|
#to_summary_plain ⇒ Object
19
20
21
22
23
|
# File 'lib/repubmark/elems/canvas.rb', line 19
def to_summary_plain
return if @items.empty?
@items.filter_map(&:to_summary_plain).join(' ').freeze
end
|
#ulist {|list| ... } ⇒ Object
96
97
98
99
100
101
|
# File 'lib/repubmark/elems/canvas.rb', line 96
def ulist
list = List.new self, links: false, ordered: false
@items << list
yield list
nil
end
|
#word_count ⇒ Object
17
|
# File 'lib/repubmark/elems/canvas.rb', line 17
def word_count = @items.sum(&:word_count)
|