Class: PostRunner::ActivityLink
- Inherits:
-
Object
- Object
- PostRunner::ActivityLink
- Defined in:
- lib/postrunner/ActivityLink.rb
Overview
Generates the name of an Activity with a link to the ActivityReport. Optionally, an icon can be shown for Activities that contain a current personal record.
Instance Method Summary collapse
-
#initialize(activity, show_record_icon = false) ⇒ ActivityLink
constructor
A new instance of ActivityLink.
-
#to_html(doc) ⇒ Object
Add the ActivityLink as HTML Elements to the document.
-
#to_s ⇒ Object
Convert the ActivityLink into a plain text form.
Constructor Details
#initialize(activity, show_record_icon = false) ⇒ ActivityLink
Returns a new instance of ActivityLink.
22 23 24 25 |
# File 'lib/postrunner/ActivityLink.rb', line 22 def initialize(activity, show_record_icon = false) @activity = activity @show_record_icon = show_record_icon end |
Instance Method Details
#to_html(doc) ⇒ Object
Add the ActivityLink as HTML Elements to the document.
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/postrunner/ActivityLink.rb', line 29 def to_html(doc) doc.unique(:activitylink_style) { doc.style(style) } doc.a(@activity.name, { :class => 'activity_link', :href => @activity.html_file_name(false) }) if @show_record_icon && @activity.has_records? doc.img(nil, { :src => 'icons/record-small.png', :style => 'vertical-align:middle' }) end end |
#to_s ⇒ Object
Convert the ActivityLink into a plain text form. Return the first 20 characters of the Activity name.
42 43 44 |
# File 'lib/postrunner/ActivityLink.rb', line 42 def to_s @activity.name[0..19] end |