Class: Marsdawn::Site::Link
- Inherits:
-
Object
- Object
- Marsdawn::Site::Link
- Defined in:
- lib/marsdawn/site/link.rb
Instance Attribute Summary collapse
-
#full_path ⇒ Object
readonly
Returns the value of attribute full_path.
-
#site ⇒ Object
readonly
Returns the value of attribute site.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(site, uri, title = nil) ⇒ Link
constructor
A new instance of Link.
- #page ⇒ Object
- #to_html ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(site, uri, title = nil) ⇒ Link
Returns a new instance of Link.
7 8 9 10 11 12 |
# File 'lib/marsdawn/site/link.rb', line 7 def initialize site, uri, title=nil @uri = uri @title = (title.nil? ? site.page_title(uri) : title) @site = site @full_path = @site.full_path(@uri) end |
Instance Attribute Details
#full_path ⇒ Object (readonly)
Returns the value of attribute full_path.
5 6 7 |
# File 'lib/marsdawn/site/link.rb', line 5 def full_path @full_path end |
#site ⇒ Object (readonly)
Returns the value of attribute site.
5 6 7 |
# File 'lib/marsdawn/site/link.rb', line 5 def site @site end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
5 6 7 |
# File 'lib/marsdawn/site/link.rb', line 5 def title @title end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
5 6 7 |
# File 'lib/marsdawn/site/link.rb', line 5 def uri @uri end |
Instance Method Details
#page ⇒ Object
14 15 16 |
# File 'lib/marsdawn/site/link.rb', line 14 def page @site.page @uri end |
#to_html ⇒ Object
22 23 24 25 |
# File 'lib/marsdawn/site/link.rb', line 22 def to_html t = CGI.escapeHTML(@title) %!<a href="#{@full_path}" title="#{t}">#{t}</a>! end |
#to_s ⇒ Object
18 19 20 |
# File 'lib/marsdawn/site/link.rb', line 18 def to_s to_html end |