Top Level Namespace
Defined Under Namespace
Modules: Googlecalendar, Net
Instance Method Summary collapse
- #html(calendar, filename) ⇒ Object
-
#parse(data) ⇒ Object
require ‘uri’.
- #scan(ical_url, base_url = 'www.google.com') ⇒ Object
- #scan_proxy(proxy_addr, proxy_port, ical_url, base_url = 'www.google.com') ⇒ Object
-
#text(calendar, filename) ⇒ Object
Builder DSL.
Instance Method Details
#html(calendar, filename) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/googlecalendar/dsl.rb', line 44 def html(calendar, filename) dirname = File.dirname(filename) Dir.mkdir(dirname) unless File.exists?(dirname) html_builder = Googlecalendar::HtmlBuilder.new html_builder.calendar = calendar html_builder.filename = filename html_builder.date_format = "%d-%m-%y" #"%F"#"%A %B %d %Y" #"%d-%m-%Y" html_builder.export end |
#parse(data) ⇒ Object
require ‘uri’
5 6 7 8 |
# File 'lib/googlecalendar/dsl.rb', line 5 def parse(data) parser = Googlecalendar::ICALParser.new parser.parse(data) end |
#scan(ical_url, base_url = 'www.google.com') ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/googlecalendar/dsl.rb', line 10 def scan(ical_url, base_url='www.google.com') Net::HTTP.start(base_url, 80) do |http| response, data = http.get(ical_url) case response when Net::HTTPSuccess, Net::HTTPRedirection return data else response.error! end end end |
#scan_proxy(proxy_addr, proxy_port, ical_url, base_url = 'www.google.com') ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/googlecalendar/dsl.rb', line 22 def scan_proxy(proxy_addr, proxy_port, ical_url, base_url='www.google.com') Net::HTTP::Proxy(proxy_addr, proxy_port).start(base_url, 80) do |http| response, data = http.get(ical_url) case response when Net::HTTPSuccess, Net::HTTPRedirection return data else response.error! end end end |
#text(calendar, filename) ⇒ Object
Builder DSL
35 36 37 38 39 40 41 42 |
# File 'lib/googlecalendar/dsl.rb', line 35 def text(calendar, filename) dirname = File.dirname(filename) Dir.mkdir(dirname) unless File.exists?(dirname) text_builder = Googlecalendar::TextBuilder.new text_builder.calendar = calendar text_builder.filename = filename text_builder.export end |