Class: Rembrandt::Formatters::FormattedCode

Inherits:
Object
  • Object
show all
Defined in:
lib/rembrandt/formatters/formatted_code.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#codeObject (readonly)

Returns the value of attribute code.



4
5
6
# File 'lib/rembrandt/formatters/formatted_code.rb', line 4

def code
  @code
end

#languageObject (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_countObject



11
12
13
# File 'lib/rembrandt/formatters/formatted_code.rb', line 11

def line_count
  code.lines.count
end