Class: Sprockets::SourceFile

Inherits:
Object
  • Object
show all
Defined in:
lib/sprockets/source_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environment, pathname) ⇒ SourceFile

Returns a new instance of SourceFile.



5
6
7
8
# File 'lib/sprockets/source_file.rb', line 5

def initialize(environment, pathname)
  @environment = environment
  @pathname = pathname
end

Instance Attribute Details

#environmentObject (readonly)

Returns the value of attribute environment.



3
4
5
# File 'lib/sprockets/source_file.rb', line 3

def environment
  @environment
end

#pathnameObject (readonly)

Returns the value of attribute pathname.



3
4
5
# File 'lib/sprockets/source_file.rb', line 3

def pathname
  @pathname
end

Instance Method Details

#==(source_file) ⇒ Object



22
23
24
# File 'lib/sprockets/source_file.rb', line 22

def ==(source_file)
  pathname == source_file.pathname
end

#each_source_lineObject



10
11
12
13
14
15
16
# File 'lib/sprockets/source_file.rb', line 10

def each_source_line
  File.open(pathname.absolute_location) do |file|
    file.each do |line|
      yield SourceLine.new(self, line, file.lineno)
    end
  end
end

#find(location, kind = :file) ⇒ Object



18
19
20
# File 'lib/sprockets/source_file.rb', line 18

def find(location, kind = :file)
  pathname.parent_pathname.find(location, kind)
end

#mtimeObject



26
27
28
29
30
# File 'lib/sprockets/source_file.rb', line 26

def mtime
  File.mtime(pathname.absolute_location)
rescue Errno::ENOENT
  0
end