Module: Vpim::Icalendar::Property::Base
Overview
FIXME - rename Base to Util
Instance Method Summary collapse
-
#propduration(endfield) ⇒ Object
Duration has “almost” the same definition for Event and Todo.
- #propend(endfield) ⇒ Object
-
#propinteger(name) ⇒ Object
:nodoc:.
-
#proptext(name) ⇒ Object
Value as TEXT of first property with name
name
. -
#proptextarray(name) ⇒ Object
Array of values as TEXT of all properties with name
name
. -
#proptextlistarray(name) ⇒ Object
Array of values as TEXT list of all properties with name
name
. -
#proptime(name) ⇒ Object
Value as DATE-TIME or DATE of object of first property with name
name
. -
#proptoken(name, allowed, default_token = nil) ⇒ Object
:nodoc:.
-
#propvalue(name) ⇒ Object
Value of first property with name
name
. -
#propvaluearray(name) ⇒ Object
Array of values of all properties with name
name
.
Instance Method Details
#propduration(endfield) ⇒ Object
Duration has “almost” the same definition for Event and Todo
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/vpim/property/base.rb', line 161 def propduration(endfield) dur = @properties.field 'DURATION' dte = @properties.field endfield if !dur return nil unless dte b = dtstart e = send(endfield.downcase.to_sym) return (e - b).to_i end Icalendar.decode_duration(dur.value_raw) end |
#propend(endfield) ⇒ Object
177 178 179 180 181 182 183 184 185 186 |
# File 'lib/vpim/property/base.rb', line 177 def propend(endfield) dte = @properties.field endfield.to_s.upcase if dte dte.to_time.first elsif duration dtstart + duration else nil end end |
#propinteger(name) ⇒ Object
:nodoc:
109 110 111 112 113 114 115 |
# File 'lib/vpim/property/base.rb', line 109 def propinteger(name) #:nodoc: prop = @properties.detect { |f| f.name? name } if prop prop = Vpim.decode_integer(prop.value) end prop end |
#proptext(name) ⇒ Object
Value as TEXT of first property with name name
142 143 144 145 146 147 148 |
# File 'lib/vpim/property/base.rb', line 142 def proptext(name) #:nodoc: prop = @properties.detect { |f| f.name? name } if prop prop = prop.to_text end prop end |
#proptextarray(name) ⇒ Object
Array of values as TEXT of all properties with name name
151 152 153 |
# File 'lib/vpim/property/base.rb', line 151 def proptextarray(name) #:nodoc: @properties.select{ |f| f.name? name }.map{ |p| p.to_text } end |
#proptextlistarray(name) ⇒ Object
Array of values as TEXT list of all properties with name name
156 157 158 |
# File 'lib/vpim/property/base.rb', line 156 def proptextlistarray(name) #:nodoc: @properties.select{ |f| f.name? name }.map{ |p| Vpim.decode_text_list(p.value_raw) }.flatten end |
#proptime(name) ⇒ Object
Value as DATE-TIME or DATE of object of first property with name name
133 134 135 136 137 138 139 |
# File 'lib/vpim/property/base.rb', line 133 def proptime(name) #:nodoc: prop = @properties.detect { |f| f.name? name } if prop prop = prop.to_time.first end prop end |
#proptoken(name, allowed, default_token = nil) ⇒ Object
:nodoc:
117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/vpim/property/base.rb', line 117 def proptoken(name, allowed, default_token = nil) #:nodoc: prop = propvalue(name) if prop prop = prop.to_str.upcase unless allowed.include?(prop) raise Vpim::InvalidEncodingError, "Invalid #{name} value '#{prop}'" end else prop = default_token end prop end |
#propvalue(name) ⇒ Object
Value of first property with name name
95 96 97 98 99 100 101 |
# File 'lib/vpim/property/base.rb', line 95 def propvalue(name) #:nodoc: prop = @properties.detect { |f| f.name? name } if prop prop = prop.value end prop end |
#propvaluearray(name) ⇒ Object
Array of values of all properties with name name
104 105 106 |
# File 'lib/vpim/property/base.rb', line 104 def propvaluearray(name) #:nodoc: @properties.select{ |f| f.name? name }.map{ |p| p.value } end |