Class: Repubmark::Elems::Note

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

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, #to_summary_plain, #word_count

Constructor Details

#initialize(parent, index, category, slug) ⇒ Note

Returns a new instance of Note.



8
9
10
11
12
13
# File 'lib/repubmark/elems/note.rb', line 8

def initialize(parent, index, category, slug)
  super parent
  @index = index
  @category = category
  @slug = slug
end

Instance Method Details

#anchorObject (private)



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

def anchor = "#@category-#@slug"

#index_unicode_supObject (private)



35
36
37
# File 'lib/repubmark/elems/note.rb', line 35

def index_unicode_sup
  @index_unicode_sup ||= Repubmark.unicode_sup @index
end

#to_gemtextObject



29
# File 'lib/repubmark/elems/note.rb', line 29

def to_gemtext = "#{index_unicode_sup}".freeze

#to_htmlObject

Basic methods #



19
20
21
22
23
24
25
26
27
# File 'lib/repubmark/elems/note.rb', line 19

def to_html
  [
    '<sup>',
    %(<a href="##{CGI.escape_html(anchor)}">),
    %([#{CGI.escape_html(@index.to_s)}]),
    '</a>',
    '</sup>',
  ].join.freeze
end