Class Ronn::Reference
In: lib/ronn/index.rb
Parent: Object

An individual index reference. A reference can point to one of a few types of locations:

  - URLs: "http://man.cx/crontab(5)"
  - Relative paths to ronn manuals: "crontab.5.ronn"

The url method should be used to obtain the href value for HTML.

Methods

manual?   new   path   relative?   remote?   ronn?   url  

Attributes

location  [R] 
name  [R] 

Public Class methods

[Source]

     # File lib/ronn/index.rb, line 149
149:     def initialize(index, name, location)
150:       @index = index
151:       @name = name
152:       @location = location
153:     end

Public Instance methods

[Source]

     # File lib/ronn/index.rb, line 155
155:     def manual?
156:       name =~ /\([0-9]\w*\)$/
157:     end

[Source]

     # File lib/ronn/index.rb, line 179
179:     def path
180:       File.expand_path(location, File.dirname(@index.path)) if relative?
181:     end

[Source]

     # File lib/ronn/index.rb, line 167
167:     def relative?
168:       !remote?
169:     end

[Source]

     # File lib/ronn/index.rb, line 163
163:     def remote?
164:       location =~ /^(?:https?|mailto):/
165:     end

[Source]

     # File lib/ronn/index.rb, line 159
159:     def ronn?
160:       location =~ /\.ronn?$/
161:     end

[Source]

     # File lib/ronn/index.rb, line 171
171:     def url
172:       if remote?
173:         location
174:       else
175:         location.chomp('.ronn') + '.html'
176:       end
177:     end

[Validate]