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.



217
218
219
220
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 217

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

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

Instance Method Details

#bufferObject



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

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

#codeObject



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

def code
  filesystem.read_path(path)
end

#location(loc) ⇒ Object



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

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

#syntaxesObject



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

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