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.
149 150 151 152 153 |
# File 'lib/ronn/index.rb', line 149 def initialize(index, name, location) @index = index @name = name @location = location end |
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
147 148 149 |
# File 'lib/ronn/index.rb', line 147 def location @location end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
146 147 148 |
# File 'lib/ronn/index.rb', line 146 def name @name end |
Instance Method Details
#manual? ⇒ Boolean
155 156 157 |
# File 'lib/ronn/index.rb', line 155 def manual? name =~ /\([0-9]\w*\)$/ end |
#path ⇒ Object
179 180 181 |
# File 'lib/ronn/index.rb', line 179 def path File.(location, File.dirname(@index.path)) if relative? end |
#relative? ⇒ Boolean
167 168 169 |
# File 'lib/ronn/index.rb', line 167 def relative? !remote? end |
#remote? ⇒ Boolean
163 164 165 |
# File 'lib/ronn/index.rb', line 163 def remote? location =~ /^(?:https?|mailto):/ end |
#ronn? ⇒ Boolean
159 160 161 |
# File 'lib/ronn/index.rb', line 159 def ronn? location =~ /\.ronn?$/ end |
#url ⇒ Object
171 172 173 174 175 176 177 |
# File 'lib/ronn/index.rb', line 171 def url if remote? location else location.chomp('.ronn') + '.html' end end |