Class: Chronograph::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/chronograph/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, date, desc, group = :default) ⇒ Event

Returns a new instance of Event.

Raises:

  • (TypeError)


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

#dateObject

Returns the value of attribute date.



5
6
7
# File 'lib/chronograph/event.rb', line 5

def date
  @date
end

#descObject

Returns the value of attribute desc.



5
6
7
# File 'lib/chronograph/event.rb', line 5

def desc
  @desc
end

#groupObject

Returns the value of attribute group.



5
6
7
# File 'lib/chronograph/event.rb', line 5

def group
  @group
end

#nameObject

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_htmlObject



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