Class: Googlecalendar::HtmlBuilder
- Inherits:
-
Object
- Object
- Googlecalendar::HtmlBuilder
- Defined in:
- lib/googlecalendar_builders.rb
Instance Attribute Summary collapse
-
#calendar ⇒ Object
Returns the value of attribute calendar.
-
#date_format ⇒ Object
Returns the value of attribute date_format.
-
#filename ⇒ Object
Returns the value of attribute filename.
Instance Method Summary collapse
- #details(event, number) ⇒ Object
- #div(object, field) ⇒ Object
- #export ⇒ Object
- #format(date) ⇒ Object
- #summary ⇒ Object
Instance Attribute Details
#calendar ⇒ Object
Returns the value of attribute calendar.
22 23 24 |
# File 'lib/googlecalendar_builders.rb', line 22 def calendar @calendar end |
#date_format ⇒ Object
Returns the value of attribute date_format.
22 23 24 |
# File 'lib/googlecalendar_builders.rb', line 22 def date_format @date_format end |
#filename ⇒ Object
Returns the value of attribute filename.
22 23 24 |
# File 'lib/googlecalendar_builders.rb', line 22 def filename @filename end |
Instance Method Details
#details(event, number) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/googlecalendar_builders.rb', line 67 def details(event, number) details = "<a href=\"javascript:displayHideSection('details" + number.to_s + "');\">Display details</a>" details << "<div id=\"details" + number.to_s + "\" class=\"details\">" details << div(event, 'start_date') details << div(event, 'end_date') details << div(event, 'time_stamp') details << div(event, 'created') details << div(event, 'last_modified') details << div(event, 'status') details << div(event, 'rrule') details << div(event, 'class_name') details << "</div>" end |
#div(object, field) ⇒ Object
81 82 83 |
# File 'lib/googlecalendar_builders.rb', line 81 def div(object, field) "<div><b>" + field.capitalize + ": </b>" + object.send(field).to_s + "</div>\n" end |
#export ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/googlecalendar_builders.rb', line 24 def export begin File.delete(@filename) rescue # if doesn't exist end File.open(@filename, File::CREAT|File::RDWR) do |file| file << "<html><head>\n" file << "<title>Calendar</tilte>\n" IO.foreach("../../html/styles.css") { |line| file << line } file << "\n" IO.foreach("../../html/scripts.js") { |line| file << line } file << "\n</head>\n<body>" file << summary event_number = 0 @calendar.events.each do |event| file << "<p class=\"event\">" file << "<h2>Event [" + event.start_date.to_s + "]</h2>" file << "<div><b>From: </b>" + event.start_date.to_s + "<b> -> To:</b> " + event.end_date.to_s + "</div>" file << div(event, 'summary') file << details(event, event_number) file << "</p>\n" event_number += 1 end file << "</body></html>" end end |
#format(date) ⇒ Object
52 53 54 |
# File 'lib/googlecalendar_builders.rb', line 52 def format(date) Date.strptime(date, @date_format) end |
#summary ⇒ Object
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/googlecalendar_builders.rb', line 56 def summary data = "<p class=\"calendar\">" data << "<h1>Calendar</h1>" data << div(@calendar, 'version') data << div(@calendar, 'scale') data << div(@calendar, 'method') data << "<div><b>number of events: </b>" + @calendar.events.size.to_s + "</div>" data << "</p>\n" return data end |