Class: Chronograph::Event
- Inherits:
-
Object
- Object
- Chronograph::Event
- Defined in:
- lib/chronograph/event.rb
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
-
#desc ⇒ Object
Returns the value of attribute desc.
-
#group ⇒ Object
Returns the value of attribute group.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, date, desc, group = :default) ⇒ Event
constructor
A new instance of Event.
- #to_table_html ⇒ Object
Constructor Details
#initialize(name, date, desc, group = :default) ⇒ Event
Returns a new instance of Event.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/chronograph/event.rb', line 6 def initialize(name, date, desc, group=:default) raise TypeError.new("date must be a date") unless date.is_a? Date raise TypeError.new("name has to be a name or symbol") unless name.is_a?(String) || name.is_a?(Symbol) raise TypeError.new("desc must be a string") unless desc.is_a? String raise TypeError.new("group has to be a name or symbol") unless group.is_a?(String) || group.is_a?(Symbol) @name = name @date = date @desc = desc @group = group end |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
5 6 7 |
# File 'lib/chronograph/event.rb', line 5 def date @date end |
#desc ⇒ Object
Returns the value of attribute desc.
5 6 7 |
# File 'lib/chronograph/event.rb', line 5 def desc @desc end |
#group ⇒ Object
Returns the value of attribute group.
5 6 7 |
# File 'lib/chronograph/event.rb', line 5 def group @group end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/chronograph/event.rb', line 5 def name @name end |
Instance Method Details
#to_table_html ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/chronograph/event.rb', line 17 def to_table_html "<tr class=\"#{@group}\">"+ "<td class=\"date\">#{@date}</td>"+ "<td class=\"name\">#{@name}</td>"+ "<td class=\"desc\">#{Kramdown::Document.new(@desc).to_html}</td>"+ "</tr>" end |