Class: Repubmark::Elems::Section
- Defined in:
- lib/repubmark/elems/section.rb
Constant Summary collapse
- SECT_HTML =
'§'
- SECT_UNICODE =
'ยง'
Instance Attribute Summary collapse
-
#count ⇒ Object
Returns the value of attribute count.
-
#text ⇒ Object
Returns the value of attribute text.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(parent, *args) ⇒ Section
constructor
A new instance of Section.
- #to_gemtext ⇒ Object
- #to_html ⇒ Object
- #to_summary_plain ⇒ Object
-
#word_count ⇒ Object
Basic methods #.
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
#count ⇒ Object
Returns the value of attribute count.
11 12 13 |
# File 'lib/repubmark/elems/section.rb', line 11 def count @count end |
#text ⇒ Object
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_gemtext ⇒ Object
37 |
# File 'lib/repubmark/elems/section.rb', line 37 def to_gemtext = "#{SECT_UNICODE * count}#{text}".freeze |
#to_html ⇒ Object
35 |
# File 'lib/repubmark/elems/section.rb', line 35 def to_html = "#{SECT_HTML * count}#{text}".freeze |
#to_summary_plain ⇒ Object
33 |
# File 'lib/repubmark/elems/section.rb', line 33 def to_summary_plain = "#{SECT_UNICODE * count}#{text}".freeze |
#word_count ⇒ Object
Basic methods #
31 |
# File 'lib/repubmark/elems/section.rb', line 31 def word_count = count_words @text |