Class: Repubmark::Elems::Text
- Inherits:
-
Base
- Object
- Base
- Repubmark::Elems::Text
show all
- Defined in:
- lib/repubmark/elems/text.rb
Direct Known Subclasses
Link
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, str, bold: false, italic: false) ⇒ Text
Returns a new instance of Text.
8
9
10
11
12
13
14
15
|
# File 'lib/repubmark/elems/text.rb', line 8
def initialize(parent, str, bold: false, italic: false)
super parent
self.str = str
@bold = !!bold
@italic = !!italic
end
|
Instance Method Details
#str=(str) ⇒ Object
31
32
33
|
# File 'lib/repubmark/elems/text.rb', line 31
def str=(str)
@str = String(str).split.join(' ').freeze
end
|
#str_to_html ⇒ Object
35
36
37
38
39
40
|
# File 'lib/repubmark/elems/text.rb', line 35
def str_to_html
result = @str
result = "<em>#{result}</em>" if @italic
result = "<strong>#{result}</strong>" if @bold
result.freeze
end
|
#to_gemtext ⇒ Object
27
|
# File 'lib/repubmark/elems/text.rb', line 27
def to_gemtext = @str
|
#to_html ⇒ Object
25
|
# File 'lib/repubmark/elems/text.rb', line 25
def to_html = str_to_html
|
#to_summary_plain ⇒ Object
23
|
# File 'lib/repubmark/elems/text.rb', line 23
def to_summary_plain = @str
|
#word_count ⇒ Object
21
|
# File 'lib/repubmark/elems/text.rb', line 21
def word_count = count_words @str
|