Class: Icalendar::Value
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Icalendar::Value
show all
- Defined in:
- lib/icalendar/value.rb
Direct Known Subclasses
Icalendar::Values::Array, Icalendar::Values::Binary, Icalendar::Values::Boolean, Icalendar::Values::Date, Icalendar::Values::DateTime, Icalendar::Values::Duration, Icalendar::Values::Float, Icalendar::Values::Integer, Icalendar::Values::Period, Icalendar::Values::Recur, Icalendar::Values::Text, Icalendar::Values::Time, Icalendar::Values::Uri, Icalendar::Values::UtcOffset
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(value, params = {}) ⇒ Value
Returns a new instance of Value.
10
11
12
13
|
# File 'lib/icalendar/value.rb', line 10
def initialize(value, params = {})
@ical_params = Icalendar::DowncasedHash(params)
super value
end
|
Instance Attribute Details
#ical_params ⇒ Object
Returns the value of attribute ical_params.
8
9
10
|
# File 'lib/icalendar/value.rb', line 8
def ical_params
@ical_params
end
|
Class Method Details
.value_type ⇒ Object
34
35
36
|
# File 'lib/icalendar/value.rb', line 34
def self.value_type
name.gsub(/\A.*::/, '').gsub(/(?<!\A)[A-Z]/, '-\0').upcase
end
|
Instance Method Details
#ical_param(key, value) ⇒ Object
15
16
17
|
# File 'lib/icalendar/value.rb', line 15
def ical_param(key, value)
@ical_params[key] = value
end
|
#params_ical ⇒ Object
28
29
30
31
32
|
# File 'lib/icalendar/value.rb', line 28
def params_ical
unless ical_params.empty?
";#{ical_params.map { |name, value| param_ical name, value }.join ';'}"
end
end
|
#to_ical(default_type) ⇒ Object
23
24
25
26
|
# File 'lib/icalendar/value.rb', line 23
def to_ical(default_type)
ical_param 'value', self.value_type if needs_value_type?(default_type)
"#{params_ical}:#{value_ical}"
end
|
#value ⇒ Object
19
20
21
|
# File 'lib/icalendar/value.rb', line 19
def value
__getobj__
end
|
#value_type ⇒ Object
38
39
40
|
# File 'lib/icalendar/value.rb', line 38
def value_type
self.class.value_type
end
|