Class: Sprockets::SourceFile
- Inherits:
-
Object
- Object
- Sprockets::SourceFile
- Defined in:
- lib/sprockets/source_file.rb
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#pathname ⇒ Object
readonly
Returns the value of attribute pathname.
Instance Method Summary collapse
- #==(source_file) ⇒ Object
- #each_source_line ⇒ Object
- #find(location, kind = :file) ⇒ Object
-
#initialize(environment, pathname) ⇒ SourceFile
constructor
A new instance of SourceFile.
- #mtime ⇒ Object
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
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
3 4 5 |
# File 'lib/sprockets/source_file.rb', line 3 def environment @environment end |
#pathname ⇒ Object (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_line ⇒ Object
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 |
#mtime ⇒ Object
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 |