Class: Repubmark::Elems::Quote

Inherits:
Base
  • Object
show all
Includes:
Joint::ForwardingBuilders
Defined in:
lib/repubmark/elems/quote.rb

Instance Attribute Summary

Attributes inherited from Base

#parent

Instance Method Summary collapse

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

#initializeQuote

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 #

Yields:



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_gemtextObject



27
# File 'lib/repubmark/elems/quote.rb', line 27

def to_gemtext = "«#{@items.map(&:to_gemtext).join(' ')}»".freeze

#to_htmlObject



25
# File 'lib/repubmark/elems/quote.rb', line 25

def to_html = "&laquo;#{@items.map(&:to_html).join("\n")}&raquo;".freeze

#to_summary_plainObject



21
22
23
# File 'lib/repubmark/elems/quote.rb', line 21

def to_summary_plain
  "«#{@items.map(&:to_summary_plain).join(' ')}»".freeze
end

#word_countObject

Basic methods #



19
# File 'lib/repubmark/elems/quote.rb', line 19

def word_count = @items.sum(&:word_count)