Class: Marsdawn::Site::Link

Inherits:
Object
  • Object
show all
Defined in:
lib/marsdawn/site/link.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_pathObject (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

#siteObject (readonly)

Returns the value of attribute site.



5
6
7
# File 'lib/marsdawn/site/link.rb', line 5

def site
  @site
end

#titleObject (readonly)

Returns the value of attribute title.



5
6
7
# File 'lib/marsdawn/site/link.rb', line 5

def title
  @title
end

#uriObject (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

#pageObject



14
15
16
# File 'lib/marsdawn/site/link.rb', line 14

def page
  @site.page @uri
end

#to_htmlObject



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_sObject



18
19
20
# File 'lib/marsdawn/site/link.rb', line 18

def to_s
  to_html
end