Class: Ronn::Reference
- Inherits:
-
Object
- Object
- Ronn::Reference
- Defined in:
- lib/ronn/index.rb
Overview
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.
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(index, name, location) ⇒ Reference
constructor
A new instance of Reference.
- #manual? ⇒ Boolean
- #path ⇒ Object
- #relative? ⇒ Boolean
- #remote? ⇒ Boolean
- #ronn? ⇒ Boolean
- #url ⇒ Object
Constructor Details
#initialize(index, name, location) ⇒ Reference
Returns a new instance of Reference.
146 147 148 149 150 |
# File 'lib/ronn/index.rb', line 146 def initialize(index, name, location) @index = index @name = name @location = location end |
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
144 145 146 |
# File 'lib/ronn/index.rb', line 144 def location @location end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
144 145 146 |
# File 'lib/ronn/index.rb', line 144 def name @name end |
Instance Method Details
#manual? ⇒ Boolean
152 153 154 |
# File 'lib/ronn/index.rb', line 152 def manual? name =~ /\([0-9]\w*\)$/ end |
#path ⇒ Object
176 177 178 |
# File 'lib/ronn/index.rb', line 176 def path File.(location, File.dirname(@index.path)) if relative? end |
#relative? ⇒ Boolean
164 165 166 |
# File 'lib/ronn/index.rb', line 164 def relative? !remote? end |
#remote? ⇒ Boolean
160 161 162 |
# File 'lib/ronn/index.rb', line 160 def remote? location =~ /^(?:https?|mailto):/ end |
#ronn? ⇒ Boolean
156 157 158 |
# File 'lib/ronn/index.rb', line 156 def ronn? location =~ /\.ronn?$/ end |
#url ⇒ Object
168 169 170 171 172 173 174 |
# File 'lib/ronn/index.rb', line 168 def url if remote? location else location.chomp('.ronn') + '.html' end end |