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.


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_paramsObject

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_typeObject


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_icalObject


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

#valueObject


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

def value
  __getobj__
end

#value_typeObject


38
39
40
# File 'lib/icalendar/value.rb', line 38

def value_type
  self.class.value_type
end