Class: Markover::Markup::CodeBlock
- Inherits:
-
Object
- Object
- Markover::Markup::CodeBlock
- Defined in:
- lib/markover/markup/code_block.rb
Overview
Class that contains data for a code block
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
Instance Method Summary collapse
-
#highlighted ⇒ String
Returns the code with syntax highlightning.
-
#initialize(id, language, code) ⇒ CodeBlock
constructor
A new instance of CodeBlock.
Constructor Details
#initialize(id, language, code) ⇒ CodeBlock
Returns a new instance of CodeBlock.
13 14 15 |
# File 'lib/markover/markup/code_block.rb', line 13 def initialize(id, language, code) @id, @language, @code = id, language, code end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
11 12 13 |
# File 'lib/markover/markup/code_block.rb', line 11 def code @code end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
11 12 13 |
# File 'lib/markover/markup/code_block.rb', line 11 def id @id end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
11 12 13 |
# File 'lib/markover/markup/code_block.rb', line 11 def language @language end |
Instance Method Details
#highlighted ⇒ String
Returns the code with syntax highlightning
19 20 21 22 23 24 25 |
# File 'lib/markover/markup/code_block.rb', line 19 def highlighted if @language CodeRay.scan(@code, @language).html(:line_numbers => :table) else CodeRay.scan(@code, :text).div end end |