Class: Guard::Tilt::OutputPath

Inherits:
Struct
  • Object
show all
Defined in:
lib/guard/tilt/output_path.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#to_strObject

Returns the value of attribute to_str

Returns:

  • (Object)

    the current value of to_str



1
2
3
# File 'lib/guard/tilt/output_path.rb', line 1

def to_str
  @to_str
end

Instance Method Details

#basename(*args) ⇒ Object



19
20
21
# File 'lib/guard/tilt/output_path.rb', line 19

def basename(*args)
  new File.basename(to_str, *args)
end

#dirnameObject



22
23
24
# File 'lib/guard/tilt/output_path.rb', line 22

def dirname
  new File.dirname(to_str)
end

#expand(*args) ⇒ Object



25
26
27
# File 'lib/guard/tilt/output_path.rb', line 25

def expand(*args)
  new File.expand_path(to_str, *args)
end

#extnameObject



16
17
18
# File 'lib/guard/tilt/output_path.rb', line 16

def extname
  new File.extname(to_str)
end

#join(other) ⇒ Object



9
10
11
# File 'lib/guard/tilt/output_path.rb', line 9

def join(other)
  new File.join(to_str, other.to_str)
end

#open(mode = 'r', &block) ⇒ Object



41
42
43
# File 'lib/guard/tilt/output_path.rb', line 41

def open(mode = 'r', &block)
  File.open(to_s, mode, &block)
end

#sanitizeObject

Template Method



5
6
7
# File 'lib/guard/tilt/output_path.rb', line 5

def sanitize
  strip_extname
end

#strip_extnameObject



29
30
31
# File 'lib/guard/tilt/output_path.rb', line 29

def strip_extname
  expand.dirname.join basename(extname)
end

#sub(base, root) ⇒ Object



12
13
14
# File 'lib/guard/tilt/output_path.rb', line 12

def sub(base, root)
  new to_str.sub(base, root)
end

#to_s(base = nil) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/guard/tilt/output_path.rb', line 33

def to_s(base = nil)
  unless base
    sanitize.to_str
  else
    base += File::Separator if base !~ /\/$/
    sanitize.sub(base, '').to_str
  end
end