Class: Builder::Ical
- Inherits:
-
BlankSlate
- Object
- BlankSlate
- Builder::Ical
show all
- Defined in:
- lib/ical_builder.rb
Instance Method Summary
collapse
Constructor Details
#initialize(options = {}) ⇒ Ical
5
6
7
|
# File 'lib/ical_builder.rb', line 5
def initialize(options = {})
@target = options[:target] || ''
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/ical_builder.rb', line 28
def method_missing(sym, *args, &block)
value = args.shift
if block
@target << "BEGIN:#{__property(sym)}\r\n"
block.call(self)
@target << "END:#{__property(sym)}\r\n"
else
@target << "#{__property(sym)}#{__parameters(args)}:#{__value(value)}\r\n"
end
end
|
Instance Method Details
#<<(str) ⇒ Object
13
14
15
|
# File 'lib/ical_builder.rb', line 13
def <<(str)
@target << str
end
|
#rrule(*args) ⇒ Object
RRULE is a special case since it needs to take a hash, but FREQ must always be first.
19
20
21
22
23
24
25
26
|
# File 'lib/ical_builder.rb', line 19
def rrule(*args)
if args[0].is_a?(Hash)
freq = __value({ :freq => args[0].delete(:freq) })
others = args[0].empty? ? nil : __value(args[0])
args[0] = [freq, others].compact.join(';')
end
method_missing(:rrule, *args)
end
|
#to_s ⇒ Object
9
10
11
|
# File 'lib/ical_builder.rb', line 9
def to_s
__fold(@target.to_s)
end
|