Class: Rembrandt::Formatters::FormattedCode
- Inherits:
-
Object
- Object
- Rembrandt::Formatters::FormattedCode
- Defined in:
- lib/rembrandt/formatters/formatted_code.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
Instance Method Summary collapse
- #extract_code_from_html(input) ⇒ Object
-
#initialize(input_code, input_language) ⇒ FormattedCode
constructor
A new instance of FormattedCode.
- #line_count ⇒ Object
Constructor Details
#initialize(input_code, input_language) ⇒ FormattedCode
Returns a new instance of FormattedCode.
6 7 8 9 |
# File 'lib/rembrandt/formatters/formatted_code.rb', line 6 def initialize(input_code, input_language) @code = extract_code_from_html(input_code) @language = input_language end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
4 5 6 |
# File 'lib/rembrandt/formatters/formatted_code.rb', line 4 def code @code end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
4 5 6 |
# File 'lib/rembrandt/formatters/formatted_code.rb', line 4 def language @language end |
Instance Method Details
#extract_code_from_html(input) ⇒ Object
15 16 17 18 |
# File 'lib/rembrandt/formatters/formatted_code.rb', line 15 def extract_code_from_html(input) matches = input.match(/<pre>(.+)<\/pre>/m) matches[1] if matches end |
#line_count ⇒ Object
11 12 13 |
# File 'lib/rembrandt/formatters/formatted_code.rb', line 11 def line_count code.lines.count end |