Class: Repubmark::Elems::Section

Inherits:
Base
  • Object
show all
Defined in:
lib/repubmark/elems/section.rb

Constant Summary collapse

SECT_HTML =
'§'
SECT_UNICODE =
'ยง'

Instance Attribute Summary collapse

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, *args) ⇒ Section

Returns a new instance of Section.



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/repubmark/elems/section.rb', line 13

def initialize(parent, *args)
  super parent

  case args.length
  when 1
    self.count = 1
    self.text = args[0]
  when 2
    self.count, self.text = args
  else
    raise ArgumentError, 'Expected 1 or 2 arguments'
  end
end

Instance Attribute Details

#countObject

Returns the value of attribute count.



11
12
13
# File 'lib/repubmark/elems/section.rb', line 11

def count
  @count
end

#textObject

Returns the value of attribute text.



11
12
13
# File 'lib/repubmark/elems/section.rb', line 11

def text
  @text
end

Instance Method Details

#to_gemtextObject



37
# File 'lib/repubmark/elems/section.rb', line 37

def to_gemtext = "#{SECT_UNICODE * count}#{text}".freeze

#to_htmlObject



35
# File 'lib/repubmark/elems/section.rb', line 35

def to_html = "#{SECT_HTML * count}#{text}".freeze

#to_summary_plainObject



33
# File 'lib/repubmark/elems/section.rb', line 33

def to_summary_plain = "#{SECT_UNICODE * count}#{text}".freeze

#word_countObject

Basic methods #



31
# File 'lib/repubmark/elems/section.rb', line 31

def word_count = count_words @text