Class: Repubmark::Elems::Quote
- Includes:
- Joint::ForwardingBuilders
- Defined in:
- lib/repubmark/elems/quote.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize ⇒ Quote
constructor
A new instance of Quote.
-
#joint {|joint| ... } ⇒ Object
Builder methods #.
- #quote(str = nil) ⇒ Object
- #to_gemtext ⇒ Object
- #to_html ⇒ Object
- #to_summary_plain ⇒ Object
-
#word_count ⇒ Object
Basic methods #.
Methods included from Joint::ForwardingBuilders
#abbrev, #bold, #code_inline, #ellipsis, #fraction, #italic, #link, #link_italic, #mdash, #power, #quote_italic, #section, #text
Methods inherited from Base
#absolute_url, #config, #count_words, #html_class, #own_url, parent?, parents, #relative_url
Constructor Details
#initialize ⇒ Quote
Returns a new instance of Quote.
10 11 12 13 |
# File 'lib/repubmark/elems/quote.rb', line 10 def initialize(...) super @items = [] end |
Instance Method Details
#joint {|joint| ... } ⇒ Object
Builder methods #
33 34 35 36 37 38 |
# File 'lib/repubmark/elems/quote.rb', line 33 def joint joint = Joint.new self yield joint @items << joint nil end |
#quote(str = nil) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/repubmark/elems/quote.rb', line 40 def quote(str = nil) quote = Quote.new self case [!!str, block_given?] when [true, false] then quote.text str when [false, true] then yield quote else raise 'Invalid args' end @items << quote nil end |
#to_gemtext ⇒ Object
27 |
# File 'lib/repubmark/elems/quote.rb', line 27 def to_gemtext = "«#{@items.map(&:to_gemtext).join(' ')}»".freeze |
#to_html ⇒ Object
25 |
# File 'lib/repubmark/elems/quote.rb', line 25 def to_html = "«#{@items.map(&:to_html).join("\n")}»".freeze |
#to_summary_plain ⇒ Object
21 22 23 |
# File 'lib/repubmark/elems/quote.rb', line 21 def to_summary_plain "«#{@items.map(&:to_summary_plain).join(' ')}»".freeze end |
#word_count ⇒ Object
Basic methods #
19 |
# File 'lib/repubmark/elems/quote.rb', line 19 def word_count = @items.sum(&:word_count) |