Class: Rackful::Path

Inherits:
String show all
Defined in:
gems/rackful-0.1.1/lib/rackful_path.rb,
gems/rackful-0.1.1.orig/lib/rackful_path.rb

Overview

Relative URI (a path)

Instance Method Summary (collapse)

Methods inherited from String

#to_path

Instance Method Details

- (Array<String>) segments

An array of unencoded segments

Returns:

  • (Array<String>)

    An array of unencoded segments



54
55
56
57
58
# File 'gems/rackful-0.1.1/lib/rackful_path.rb', line 54

def segments
  r = self.split('/').collect { |s| Rack::Utils.unescape( s, Encoding::UTF_8 ) }
  r.shift
  r
end

- (void) slashify



22
23
24
25
26
# File 'gems/rackful-0.1.1/lib/rackful_path.rb', line 22

def slashify
  r = self.dup
  r << '/' if '/' != r[-1,1]
  r
end

- (void) slashify!



28
29
30
31
32
33
34
# File 'gems/rackful-0.1.1/lib/rackful_path.rb', line 28

def slashify!
  if '/' != self[-1,1]
    self << '/'
  else
    nil
  end
end

- (void) unescape(encoding = Encoding::UTF_8)

An alias for Rack::Utils.unescape



51
# File 'gems/rackful-0.1.1/lib/rackful_path.rb', line 51

def unescape( encoding = Encoding::UTF_8 ); Rack::Utils.unescape(self, encoding); end

- (void) unslashify



36
37
38
39
40
# File 'gems/rackful-0.1.1/lib/rackful_path.rb', line 36

def unslashify
  r = self.dup
  r = r.chomp( '/' ) if '/' == r[-1,1]
  r
end

- (void) unslashify!



42
43
44
45
46
47
48
# File 'gems/rackful-0.1.1/lib/rackful_path.rb', line 42

def unslashify!
  if '/' == self[-1,1]
    self.chomp! '/'
  else
    nil
  end
end