Class: Sprockets::Pathname
- Inherits:
-
Object
- Object
- Sprockets::Pathname
- Defined in:
- lib/sprockets/pathname.rb
Instance Attribute Summary collapse
-
#absolute_location ⇒ Object
readonly
Returns the value of attribute absolute_location.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
Instance Method Summary collapse
- #==(pathname) ⇒ Object
- #contents ⇒ Object
-
#find(location, kind = :file) ⇒ Object
Returns a Pathname for the location relative to this pathname’s absolute location.
-
#initialize(environment, absolute_location) ⇒ Pathname
constructor
A new instance of Pathname.
- #parent_pathname ⇒ Object
- #source_file ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(environment, absolute_location) ⇒ Pathname
Returns a new instance of Pathname.
5 6 7 8 |
# File 'lib/sprockets/pathname.rb', line 5 def initialize(environment, absolute_location) @environment = environment @absolute_location = File.(absolute_location) end |
Instance Attribute Details
#absolute_location ⇒ Object (readonly)
Returns the value of attribute absolute_location.
3 4 5 |
# File 'lib/sprockets/pathname.rb', line 3 def absolute_location @absolute_location end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
3 4 5 |
# File 'lib/sprockets/pathname.rb', line 3 def environment @environment end |
Instance Method Details
#==(pathname) ⇒ Object
28 29 30 31 |
# File 'lib/sprockets/pathname.rb', line 28 def ==(pathname) environment == pathname.environment && absolute_location == pathname.absolute_location end |
#contents ⇒ Object
24 25 26 |
# File 'lib/sprockets/pathname.rb', line 24 def contents IO.read(absolute_location) end |
#find(location, kind = :file) ⇒ Object
Returns a Pathname for the location relative to this pathname’s absolute location.
11 12 13 14 |
# File 'lib/sprockets/pathname.rb', line 11 def find(location, kind = :file) location = File.join(absolute_location, location) File.send("#{kind}?", location) ? Pathname.new(environment, location) : nil end |
#parent_pathname ⇒ Object
16 17 18 |
# File 'lib/sprockets/pathname.rb', line 16 def parent_pathname Pathname.new(environment, File.dirname(absolute_location)) end |
#source_file ⇒ Object
20 21 22 |
# File 'lib/sprockets/pathname.rb', line 20 def source_file SourceFile.new(environment, self) end |
#to_s ⇒ Object
33 34 35 |
# File 'lib/sprockets/pathname.rb', line 33 def to_s absolute_location end |