Class: Icalendar::Value

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/icalendar/value.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, params = {}) ⇒ Value

Returns a new instance of Value.



9
10
11
12
# File 'lib/icalendar/value.rb', line 9

def initialize(value, params = {})
  @ical_params = params.dup
  super value
end

Instance Attribute Details

#ical_paramsObject

Returns the value of attribute ical_params.



7
8
9
# File 'lib/icalendar/value.rb', line 7

def ical_params
  @ical_params
end

Class Method Details

.value_typeObject



33
34
35
# File 'lib/icalendar/value.rb', line 33

def self.value_type
  name.gsub(/\A.*::/, '').gsub(/(?<!\A)[A-Z]/, '-\0').upcase
end

Instance Method Details

#ical_param(key, value) ⇒ Object



14
15
16
# File 'lib/icalendar/value.rb', line 14

def ical_param(key, value)
  @ical_params[key.to_s] = value
end

#params_icalObject



27
28
29
30
31
# File 'lib/icalendar/value.rb', line 27

def params_ical
  unless ical_params.empty?
    ";#{ical_params.map { |name, value| param_ical name, value }.join ';'}"
  end
end

#to_ical(default_type) ⇒ Object



22
23
24
25
# File 'lib/icalendar/value.rb', line 22

def to_ical(default_type)
  ical_param 'value', self.class.value_type if needs_value_type?(default_type)
  "#{params_ical}:#{value_ical}"
end

#valueObject



18
19
20
# File 'lib/icalendar/value.rb', line 18

def value
  __getobj__
end