Class: Murdoc::Paragraph
- Inherits:
-
Object
- Object
- Murdoc::Paragraph
- Defined in:
- lib/murdoc/paragraph.rb,
lib/murdoc/languages/ruby.rb,
lib/murdoc/languages/javascript.rb
Instance Attribute Summary collapse
-
#annotation ⇒ Object
Returns the value of attribute annotation.
-
#options ⇒ Object
Returns the value of attribute options.
-
#source ⇒ Object
Returns the value of attribute source.
-
#source_type ⇒ Object
Returns the value of attribute source_type.
-
#starting_line ⇒ Object
Returns the value of attribute starting_line.
Instance Method Summary collapse
- #formatted_annotation ⇒ Object
- #formatted_source ⇒ Object
-
#initialize(source, annotation, starting_line = 0, source_type = nil, options = {}) ⇒ Paragraph
constructor
A new instance of Paragraph.
Constructor Details
#initialize(source, annotation, starting_line = 0, source_type = nil, options = {}) ⇒ Paragraph
Returns a new instance of Paragraph.
14 15 16 17 18 19 20 |
# File 'lib/murdoc/paragraph.rb', line 14 def initialize(source, annotation, starting_line = 0, source_type = nil, ={}) self.source = source self.annotation = annotation self.starting_line = starting_line self.source_type = source_type self. = end |
Instance Attribute Details
#annotation ⇒ Object
Returns the value of attribute annotation.
9 10 11 |
# File 'lib/murdoc/paragraph.rb', line 9 def annotation @annotation end |
#options ⇒ Object
Returns the value of attribute options.
12 13 14 |
# File 'lib/murdoc/paragraph.rb', line 12 def @options end |
#source ⇒ Object
Returns the value of attribute source.
8 9 10 |
# File 'lib/murdoc/paragraph.rb', line 8 def source @source end |
#source_type ⇒ Object
Returns the value of attribute source_type.
10 11 12 |
# File 'lib/murdoc/paragraph.rb', line 10 def source_type @source_type end |
#starting_line ⇒ Object
Returns the value of attribute starting_line.
11 12 13 |
# File 'lib/murdoc/paragraph.rb', line 11 def starting_line @starting_line end |
Instance Method Details
#formatted_annotation ⇒ Object
31 32 33 |
# File 'lib/murdoc/paragraph.rb', line 31 def formatted_annotation Markdown.new(annotation, :smart).to_html end |
#formatted_source ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/murdoc/paragraph.rb', line 35 def formatted_source @formatted_source ||= if pygments_installed? && [:highlight_source] IO.popen("pygmentize -l #{source_type} -f html", "w+") do |pipe| pipe.puts source pipe.close_write pipe.read end else "<pre>" + CGI.escapeHTML(source) + "</pre>" end end |