Module: Vpim::Icalendar::Set::Util
- Included in:
- Vevent::Maker
- Defined in:
- lib/vpim/property/base.rb
Overview
:nodoc:
Instance Method Summary collapse
- #add_address(name, value) ⇒ Object
- #field_create(name, value, default_value_type = nil, value_type = nil, params = {}) ⇒ Object
-
#rm_all(name) ⇒ Object
TODO - rename module to Private?.
- #set_address(name, value) ⇒ Object
- #set_date_or_datetime(name, default, value) ⇒ Object
- #set_datetime(name, value) ⇒ Object
- #set_integer(name, value) ⇒ Object
- #set_text(name, value) ⇒ Object
- #set_text_list(name, value) ⇒ Object
-
#set_token(name, allowed, default, value) ⇒ Object
:nodoc:.
Instance Method Details
#add_address(name, value) ⇒ Object
78 79 80 81 |
# File 'lib/vpim/property/base.rb', line 78 def add_address(name, value) f = value.encode(name) @comp.properties.push(f) end |
#field_create(name, value, default_value_type = nil, value_type = nil, params = {}) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/vpim/property/base.rb', line 32 def field_create(name, value, default_value_type = nil, value_type = nil, params = {}) if value_type && value_type != default_value_type params['VALUE'] = value_type end Vpim::DirectoryInfo::Field.create(name, value, params) end |
#rm_all(name) ⇒ Object
TODO - rename module to Private?
16 17 18 19 |
# File 'lib/vpim/property/base.rb', line 16 def rm_all(name) rm = @comp.properties.select { |f| f.name? name } rm.each { |f| @comp.properties.delete(f) } end |
#set_address(name, value) ⇒ Object
83 84 85 86 |
# File 'lib/vpim/property/base.rb', line 83 def set_address(name, value) rm_all(name) add_address(name, value) end |
#set_date_or_datetime(name, default, value) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/vpim/property/base.rb', line 39 def set_date_or_datetime(name, default, value) f = nil case value when Date f = field_create(name, Vpim.encode_date(value), default, 'DATE') when Time f = field_create(name, Vpim.encode_date_time(value), default, 'DATE-TIME') else raise Vpim::Unencodeable, "Invalid #{name} value #{value.inspect}" end rm_all(name) @comp.properties.push(f) end |
#set_datetime(name, value) ⇒ Object
53 54 55 56 57 |
# File 'lib/vpim/property/base.rb', line 53 def set_datetime(name, value) f = field_create(name, Vpim.encode_date_time(value)) rm_all(name) @comp.properties.push(f) end |
#set_integer(name, value) ⇒ Object
71 72 73 74 75 76 |
# File 'lib/vpim/property/base.rb', line 71 def set_integer(name, value) value = value.to_int.to_s f = field_create(name, value) rm_all(name) @comp.properties.push(f) end |
#set_text(name, value) ⇒ Object
59 60 61 62 63 |
# File 'lib/vpim/property/base.rb', line 59 def set_text(name, value) f = field_create(name, Vpim.encode_text(value)) rm_all(name) @comp.properties.push(f) end |
#set_text_list(name, value) ⇒ Object
65 66 67 68 69 |
# File 'lib/vpim/property/base.rb', line 65 def set_text_list(name, value) f = field_create(name, Vpim.encode_text_list(value)) rm_all(name) @comp.properties.push(f) end |
#set_token(name, allowed, default, value) ⇒ Object
:nodoc:
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/vpim/property/base.rb', line 21 def set_token(name, allowed, default, value) #:nodoc: value = value.to_str unless allowed.include?(value) raise Vpim::Unencodeable, "Invalid #{name} value '#{value}'" end rm_all(name) unless value == default @comp.properties.push Vpim::DirectoryInfo::Field.create(name, value) end end |