Class: ICS::Event
- Inherits:
-
Object
- Object
- ICS::Event
- Defined in:
- lib/ics/event.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#alarmuid ⇒ Object
Returns the value of attribute alarmuid.
-
#attach ⇒ Object
Returns the value of attribute attach.
-
#attendee ⇒ Object
Returns the value of attribute attendee.
-
#categories ⇒ Object
Returns the value of attribute categories.
-
#created ⇒ Object
Returns the value of attribute created.
-
#description ⇒ Object
Returns the value of attribute description.
-
#dtend ⇒ Object
Returns the value of attribute dtend.
-
#dtstamp ⇒ Object
Returns the value of attribute dtstamp.
-
#dtstart ⇒ Object
Returns the value of attribute dtstart.
-
#last_modified ⇒ Object
Returns the value of attribute last_modified.
-
#location ⇒ Object
Returns the value of attribute location.
-
#sequence ⇒ Object
Returns the value of attribute sequence.
-
#status ⇒ Object
Returns the value of attribute status.
-
#summary ⇒ Object
Returns the value of attribute summary.
-
#transp ⇒ Object
Returns the value of attribute transp.
-
#trigger ⇒ Object
Returns the value of attribute trigger.
-
#uid ⇒ Object
Returns the value of attribute uid.
-
#url ⇒ Object
Returns the value of attribute url.
-
#x_apple_default_alarm ⇒ Object
Returns the value of attribute x_apple_default_alarm.
-
#x_wr_alarmuid ⇒ Object
Returns the value of attribute x_wr_alarmuid.
Class Method Summary collapse
-
.file(file) ⇒ Object
Given an exported ical file, parse it and create events.
-
.parse(str) ⇒ Object
Parse data and return new Event.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Event
constructor
A new instance of Event.
Constructor Details
#initialize(attributes = {}) ⇒ Event
Returns a new instance of Event.
29 30 31 32 33 |
# File 'lib/ics/event.rb', line 29 def initialize(attributes = {}) attributes.each do |key, val| send("#{key}=", val) end end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
7 8 9 |
# File 'lib/ics/event.rb', line 7 def action @action end |
#alarmuid ⇒ Object
Returns the value of attribute alarmuid.
8 9 10 |
# File 'lib/ics/event.rb', line 8 def alarmuid @alarmuid end |
#attach ⇒ Object
Returns the value of attribute attach.
9 10 11 |
# File 'lib/ics/event.rb', line 9 def attach @attach end |
#attendee ⇒ Object
Returns the value of attribute attendee.
10 11 12 |
# File 'lib/ics/event.rb', line 10 def attendee @attendee end |
#categories ⇒ Object
Returns the value of attribute categories.
11 12 13 |
# File 'lib/ics/event.rb', line 11 def categories @categories end |
#created ⇒ Object
Returns the value of attribute created.
12 13 14 |
# File 'lib/ics/event.rb', line 12 def created @created end |
#description ⇒ Object
Returns the value of attribute description.
13 14 15 |
# File 'lib/ics/event.rb', line 13 def description @description end |
#dtend ⇒ Object
Returns the value of attribute dtend.
14 15 16 |
# File 'lib/ics/event.rb', line 14 def dtend @dtend end |
#dtstamp ⇒ Object
Returns the value of attribute dtstamp.
15 16 17 |
# File 'lib/ics/event.rb', line 15 def dtstamp @dtstamp end |
#dtstart ⇒ Object
Returns the value of attribute dtstart.
16 17 18 |
# File 'lib/ics/event.rb', line 16 def dtstart @dtstart end |
#last_modified ⇒ Object
Returns the value of attribute last_modified.
17 18 19 |
# File 'lib/ics/event.rb', line 17 def last_modified @last_modified end |
#location ⇒ Object
Returns the value of attribute location.
18 19 20 |
# File 'lib/ics/event.rb', line 18 def location @location end |
#sequence ⇒ Object
Returns the value of attribute sequence.
19 20 21 |
# File 'lib/ics/event.rb', line 19 def sequence @sequence end |
#status ⇒ Object
Returns the value of attribute status.
20 21 22 |
# File 'lib/ics/event.rb', line 20 def status @status end |
#summary ⇒ Object
Returns the value of attribute summary.
21 22 23 |
# File 'lib/ics/event.rb', line 21 def summary @summary end |
#transp ⇒ Object
Returns the value of attribute transp.
22 23 24 |
# File 'lib/ics/event.rb', line 22 def transp @transp end |
#trigger ⇒ Object
Returns the value of attribute trigger.
23 24 25 |
# File 'lib/ics/event.rb', line 23 def trigger @trigger end |
#uid ⇒ Object
Returns the value of attribute uid.
24 25 26 |
# File 'lib/ics/event.rb', line 24 def uid @uid end |
#url ⇒ Object
Returns the value of attribute url.
25 26 27 |
# File 'lib/ics/event.rb', line 25 def url @url end |
#x_apple_default_alarm ⇒ Object
Returns the value of attribute x_apple_default_alarm.
26 27 28 |
# File 'lib/ics/event.rb', line 26 def x_apple_default_alarm @x_apple_default_alarm end |
#x_wr_alarmuid ⇒ Object
Returns the value of attribute x_wr_alarmuid.
27 28 29 |
# File 'lib/ics/event.rb', line 27 def x_wr_alarmuid @x_wr_alarmuid end |
Class Method Details
.file(file) ⇒ Object
Given an exported ical file, parse it and create events.
38 39 40 41 42 43 44 45 46 |
# File 'lib/ics/event.rb', line 38 def file(file) # format line endings. content = file.readlines.map(&:chomp).join($/) line_ending = $/ content.split("BEGIN:VEVENT#{line_ending}")[1..-1].map do |data_string| data_string = data_string.split("END:VEVENT#{line_ending}").first parse(data_string) end end |
.parse(str) ⇒ Object
Parse data and return new Event.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/ics/event.rb', line 49 def parse(str) chunks = chunk(str.split($/)) attributes = chunks.inject({}) do |hash, line| key, value = line.split(':', 2) next hash if key =~ /^BEGIN$|^END$/ # Ignore any other book ends. value = value.chomp if value key = key. split(';', 2). first. # Ignore extra data other than just the name of the attribute. gsub('-', '_') # underscore. hash[key.downcase.to_sym] = value hash end new(attributes) end |