Class: Elisp::Heading
- Inherits:
-
Object
- Object
- Elisp::Heading
- Defined in:
- lib/elisp.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
Instance Method Summary collapse
- #html ⇒ Object
- #html_id ⇒ Object
-
#initialize(content, level: 2) ⇒ Heading
constructor
A new instance of Heading.
Constructor Details
#initialize(content, level: 2) ⇒ Heading
55 56 57 58 |
# File 'lib/elisp.rb', line 55 def initialize(content, level: 2) @content = content @level = level end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
53 54 55 |
# File 'lib/elisp.rb', line 53 def content @content end |
#level ⇒ Object (readonly)
Returns the value of attribute level.
53 54 55 |
# File 'lib/elisp.rb', line 53 def level @level end |
Instance Method Details
#html ⇒ Object
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/elisp.rb', line 60 def html name = "h#{@level}" content = CGI.escape_html(@content) " <\#{name} id=\"\#{html_id}\">\n \#{content}\n <a href=\"#\#{html_id}\">#</a>\n </\#{name}>\n END_HTML\nend\n" |
#html_id ⇒ Object
71 72 73 74 |
# File 'lib/elisp.rb', line 71 def html_id content = CGI.escape(@content) "#{@level}-#{content}" end |