class HamlLint::Source

Wrapper class representing a single target for HamlLint::Runner to run against, comprised of a file path to eventually read from, and an optional IO argument to override with.

Attributes

path[R]

@return [String] File path associated with the given IO object.

Public Class Methods

new(path: nil, io: nil) click to toggle source

Wraps an optional IO object and file path to a source object.

@param [String] path @param [IO] io

# File lib/haml_lint/source.rb, line 14
def initialize(path: nil, io: nil)
  @path = path
  @io = io
end

Public Instance Methods

contents() click to toggle source

@return [String] Contents of the given IO object.

# File lib/haml_lint/source.rb, line 20
def contents
  @contents ||= @io&.read || File.read(path)
end