Class: Sprockets::Pathname

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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.expand_path(absolute_location)
end

Instance Attribute Details

#absolute_locationObject (readonly)

Returns the value of attribute absolute_location.



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

def absolute_location
  @absolute_location
end

#environmentObject (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

#contentsObject



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_pathnameObject



16
17
18
# File 'lib/sprockets/pathname.rb', line 16

def parent_pathname
  Pathname.new(environment, File.dirname(absolute_location))
end

#source_fileObject



20
21
22
# File 'lib/sprockets/pathname.rb', line 20

def source_file
  SourceFile.new(environment, self)
end

#to_sObject



33
34
35
# File 'lib/sprockets/pathname.rb', line 33

def to_s
  absolute_location
end