Class: CC::Analyzer::Formatters::HTMLFormatter::SourceFile

Inherits:
Object
  • Object
show all
Defined in:
lib/cc/analyzer/formatters/html_formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, filesystem) ⇒ SourceFile

Returns a new instance of SourceFile.



221
222
223
224
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 221

def initialize(path, filesystem)
  @path = path
  @filesystem = filesystem
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



226
227
228
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 226

def path
  @path
end

Instance Method Details

#bufferObject



237
238
239
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 237

def buffer
  @buffer ||= SourceBuffer.new(path, code)
end

#codeObject



233
234
235
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 233

def code
  filesystem.read_path(path)
end

#location(loc) ⇒ Object



241
242
243
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 241

def location(loc)
  Location.new(buffer, loc)
end

#syntaxesObject



228
229
230
231
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 228

def syntaxes
  ext = File.basename(path).split(".").last.downcase
  Array(LANGUAGES[ext])
end