Class: Vcard::V4_0::Typegrammars

Inherits:
Object
  • Object
show all
Defined in:
lib/vobject/vcard/v4_0/typegrammars.rb

Class Method Summary collapse

Class Method Details

.addressObject



329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
# File 'lib/vobject/vcard/v4_0/typegrammars.rb', line 329

def address
  component = seq(C::COMPONENT4 << ",".r, lazy { component }) do |(a, b)|
    [unescape_component(a), b].flatten
  end | C::COMPONENT4.map { |t| [unescape_component(t)] }
  address = seq(component << ";".r, component << ";".r,
                component << ";".r, component << ";".r,
                component << ";".r, component << ";".r,
                component) do |(a, b, c, d, e, f, g)|
                  a = a[0] if a.length == 1
                  b = b[0] if b.length == 1
                  c = c[0] if c.length == 1
                  d = d[0] if d.length == 1
                  e = e[0] if e.length == 1
                  f = f[0] if f.length == 1
                  g = g[0] if g.length == 1
                  PropertyValue::Address.new(pobox: a, ext: b,
                                             street: c,
                                             locality: d, region: e, code: f,
                                             country: g)
                end
  address.eof
end

.clientpidmapObject



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/vobject/vcard/v4_0/typegrammars.rb', line 44

def clientpidmap
  uri = /\S+/.r.map do |s|
    if s =~ URI::DEFAULT_PARSER.make_regexp
      s
    else
      { error: "Invalid URI" }
    end
  end
  clientpidmap = seq(/[0-9]/.r << ";".r, uri) do |(a, b)|
    PropertyValue::Clientpidmap.new(pid: a, uri: b)
  end
  clientpidmap.eof
end

.date_and_or_timeObject



222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/vobject/vcard/v4_0/typegrammars.rb', line 222

def date_and_or_time
  hour = /[0-9]{2}/.r
  minute = /[0-9]{2}/.r
  second = /[0-9]{2}/.r
  time_notrunc = seq(hour, minute, second, C::ZONE._?) do |(h, m, s, z)|
    h = { hour: h, min: m, sec: s }
    h[:zone] = z[0] unless z.empty?
    h
  end | seq(hour, minute, C::ZONE._?) do |(h, m, z)|
    h = { hour: h, min: m }
    h[:zone] = z[0] unless z.empty?
    h
  end | seq(hour, C::ZONE._?) do
    h = { hour: h }
    h[:zone] = z[0] unless z.empty?
    h
  end
  date_noreduc = seq(/[0-9]{4}/.r, /[0-9]{2}/.r, /[0-9]{2}/.r) do |(yy, mm, dd)|
    { year: yy, month: mm, day: dd }
  end | seq("--", /[0-9]{2}/.r, /[0-9]{2}/.r) do |(_, mm, dd)|
    { month: mm, day: dd }
  end | seq("--", "-", /[0-9]{2}/.r) { |(_, _, dd)| { day: dd } }
  date_time = seq(date_noreduc << "T".r, time_notrunc) { |(d, t)| d.merge t }
  date = seq(/[0-9]{4}/.r, /[0-9]{2}/.r, /[0-9]{2}/.r) do |(yy, mm, dd)|
    { year: yy, month: mm, day: dd }
  end | seq(/[0-9]{4}/.r << "-".r, /[0-9]{2}/.r) do |(yy, dd)|
    { year: yy, day: dd }
  end | /[0-9]{4}/.r do |yy|
    { year: yy }
  end | seq("--", /[0-9]{2}/.r, /[0-9]{2}/.r) do |(_, mm, dd)|
    { month: mm, day: dd }
  end | seq("--", /[0-9]{2}/.r) do |(_, mm)|
    { month: mm }
  end | seq("--", "-", /[0-9]{2}/.r) do |(_, _, dd)|
    { day: dd }
  end
  time = seq(hour, minute, second, C::ZONE._?) do |(h, m, s, z)|
    h = { hour: h, min: m, sec: s }
    h[:zone] = z[0] unless z.empty?
    h
  end | seq(hour, minute, C::ZONE._?) do |(h, m, z)|
    h = { hour: h, min: m }
    h[:zone] = z[0] unless z.empty?
    h
  end | seq(hour, C::ZONE._?) do |(h, z)|
    h = { hour: h }
    h[:zone] = z[0] unless z.empty?
    h
    # } | seq("-", minute, second, C::ZONE._?) { |(m, s, z)|
    # errata: remove zones from truncated times
  end | seq("-".r >> minute, second) do |(m, s)|
    { min: m, sec: s }
    # } | seq("-", minute, C::ZONE._?) { |(m, z)|
    # errata: remove zones from truncated times
  end | seq("-".r >> minute) do |m|
    { min: m }
    # } | seq("-", "-", second, C::ZONE._?) { |(s, z)|
    # errata: remove zones from truncated times
  end | seq("-", "-", second) do |(_, _, s)|
    { sec: s }
  end
  date_and_or_time = date_time.map do |d| 
    ret = PropertyValue::DateTimeLocal.new d 
    ret.type = "date-and-or-time"
    ret
  end | date.map do |d| 
    ret = PropertyValue::Date.new d 
    ret.type = "date-and-or-time"
    ret
  end | seq("T".r >> time).map do |t| 
    ret = PropertyValue::Time.new t 
    ret.type = "date-and-or-time"
    ret
  end
  date_and_or_time.eof
end

.date_completeObject



101
102
103
104
105
106
107
# File 'lib/vobject/vcard/v4_0/typegrammars.rb', line 101

def date_complete
  date_complete1 = seq(/[0-9]{4}/.r, /[0-9]{2}/.r, /[0-9]{2}/.r) do |(yy, mm, dd)|
    { year: yy, month: mm, day: dd }
  end
  date_complete = date_complete1.map { |d| PropertyValue::Date.new d }
  date_complete.eof
end

.date_noreducObject



89
90
91
92
93
94
95
96
97
98
99
# File 'lib/vobject/vcard/v4_0/typegrammars.rb', line 89

def date_noreduc
  date_noreduc1 = seq(/[0-9]{4}/.r, /[0-9]{2}/.r, /[0-9]{2}/.r) do |(yy, mm, dd)|
    { year: yy, month: mm, day: dd }
  end | seq("--".r >> /[0-9]{2}/.r, /[0-9]{2}/.r) do |(mm, dd)|
    { month: mm, day: dd }
  end | seq("--", "-", /[0-9]{2}/.r) do |(_, _, dd)|
    { day: dd }
  end
  date_noreduc = date_noreduc1.map { |d| PropertyValue::Date.new d }
  date_noreduc.eof
end

.date_tObject



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/vobject/vcard/v4_0/typegrammars.rb', line 71

def date_t
  date_t1 = seq(/[0-9]{4}/.r, /[0-9]{2}/.r, /[0-9]{2}/.r) do |(yy, mm, dd)|
    { year: yy, month: mm, day: dd }
  end | seq(/[0-9]{4}/.r << "-".r, /[0-9]{2}/.r) do |(yy, dd)|
    { year: yy, day: dd }
  end | /[0-9]{4}/.r do |yy|
    { year: yy }
  end | seq("--".r >> /[0-9]{2}/.r, /[0-9]{2}/.r) do |(mm, dd)|
    { month: mm, day: dd }
  end | seq("--".r >> /[0-9]{2}/.r) do |mm|
    { month: mm }
  end | seq("--", "-", /[0-9]{2}/.r) do |(_, _, dd)|
    { day: dd }
  end
  date_t = date_t1.map { |d| PropertyValue::Date.new d }
  date_t.eof
end

.date_timeObject



171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/vobject/vcard/v4_0/typegrammars.rb', line 171

def date_time
  hour = /[0-9]{2}/.r
  minute = /[0-9]{2}/.r
  second = /[0-9]{2}/.r
  time_notrunc = seq(hour, minute, second, C::ZONE._?) do |(h, m, s, z)|
    h = { hour: h, min: m, sec: s }
    h[:zone] = z[0] unless z.empty?
    h
  end | seq(hour, minute, C::ZONE._?) do |(h, m, z)|
    h = { hour: h, min: m }
    h[:zone] = z[0] unless z.empty?
    h
  end | seq(hour, C::ZONE._?) do |(h, z)|
    h = { hour: h }
    h[:zone] = z[0] unless z.empty?
    h
  end
  date_noreduc = seq(/[0-9]{4}/.r, /[0-9]{2}/.r, /[0-9]{2}/.r) do |(yy, mm, dd)|
    { year: yy, month: mm, day: dd }
  end | seq("--".r >> /[0-9]{2}/.r, /[0-9]{2}/.r) do |(mm, dd)|
    { month: mm, day: dd }
  end | seq("--", "-", /[0-9]{2}/.r) do |(_, _, dd)|
    { day: dd }
  end
  date_time = seq(date_noreduc << "T".r, time_notrunc) do |(d, t)|
    d = d.merge t
    PropertyValue::DateTimeLocal.new d
  end
  date_time.eof
end

.fivepartnameObject



311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
# File 'lib/vobject/vcard/v4_0/typegrammars.rb', line 311

def fivepartname
  component = seq(C::COMPONENT4 << ",".r, lazy { component }) do |(a, b)|
    [unescape_component(a), b].flatten
  end | C::COMPONENT4.map { |t| [unescape_component(t)] }
  fivepartname = seq(component << ";".r, component << ";".r,
                     component << ";".r, component << ";".r,
                     component) do |(a, b, c, d, e)|
                       a = a[0] if a.length == 1
                       b = b[0] if b.length == 1
                       c = c[0] if c.length == 1
                       d = d[0] if d.length == 1
                       e = e[0] if e.length == 1
                       PropertyValue::Fivepartname.new(surname: a, givenname: b,
                                                       additionalname: c, honprefix: d, honsuffix: e)
                     end
  fivepartname.eof
end

.float_tObject



18
19
20
21
# File 'lib/vobject/vcard/v4_0/typegrammars.rb', line 18

def float_t
  float_t = prim(:double).map { |f| PropertyValue::Float.new f }
  float_t.eof
end

.genderObject



352
353
354
355
356
357
358
359
# File 'lib/vobject/vcard/v4_0/typegrammars.rb', line 352

def gender
  gender1 = seq(/[MFONU]/.r._? << ";", C::TEXT4) do |(sex, gender)|
    sex = sex[0] unless sex.empty?
    { sex: sex, gender: gender }
  end | /[MFONU]/.r.map { |sex| { sex: sex, gender: "" } }
  gender = gender1.map { |g| PropertyValue::Gender.new g }
  gender.eof
end

.iana_tokenObject



23
24
25
26
# File 'lib/vobject/vcard/v4_0/typegrammars.rb', line 23

def iana_token
  iana_token = C::IANATOKEN.map { |x| PropertyValue::Ianatoken.new x }
  iana_token.eof
end

.integerObject

property value types, each defining their own parser



13
14
15
16
# File 'lib/vobject/vcard/v4_0/typegrammars.rb', line 13

def integer
  integer = prim(:int32).map { |i| PropertyValue::Integer.new i }
  integer.eof
end

.kindvalueObject



304
305
306
307
308
309
# File 'lib/vobject/vcard/v4_0/typegrammars.rb', line 304

def kindvalue
  kindvalue = (/individual/i.r | /group/i.r | /org/i.r | /location/i.r |
               /application/i.r | C::IANATOKEN |
               C::XNAME_VCARD).map { |v| PropertyValue::Kindvalue.new v }
  kindvalue.eof
end

.langObject



370
371
372
373
# File 'lib/vobject/vcard/v4_0/typegrammars.rb', line 370

def lang
  lang = C::RFC5646LANGVALUE.map { |l| PropertyValue::Lang.new l }
  lang.eof
end

.orgObject



361
362
363
364
365
366
367
368
# File 'lib/vobject/vcard/v4_0/typegrammars.rb', line 361

def org
  text = C::COMPONENT4
  org1 =
    seq(text, ";", lazy { org1 }) { |(a, _, b)| [unescape_component(a), b].flatten } |
    text.map { |t| [unescape_component(t)] }
  org = org1.map { |g| PropertyValue::Org.new g }
  org.eof
end

.text_tObject



58
59
60
61
# File 'lib/vobject/vcard/v4_0/typegrammars.rb', line 58

def text_t
  text_t = C::TEXT4.map { |t| PropertyValue::Text.new(unescape(t)) }
  text_t.eof
end

.textlistObject



63
64
65
66
67
68
69
# File 'lib/vobject/vcard/v4_0/typegrammars.rb', line 63

def textlist
  textlist1 =
    seq(C::TEXT4 << ",".r, lazy { textlist1 }) { |(a, b)| [unescape(a), b].flatten } |
    C::TEXT4.map { |t| [unescape(t)] }
  textlist = textlist1.map { |m| PropertyValue::Textlist.new m }
  textlist.eof
end

.time_completeObject



161
162
163
164
165
166
167
168
169
# File 'lib/vobject/vcard/v4_0/typegrammars.rb', line 161

def time_complete
  time_complete1 = seq(hour, minute, second, C::ZONE._?) do |(h, m, s, z)|
    h = { hour: h, min: m, sec: s }
    h[:zone] = z[0] unless z.empty?
    h
  end
  time_complete = time_complete1.map { |d| PropertyValue::Time.new d }
  time_complete.eof
end

.time_notruncObject



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/vobject/vcard/v4_0/typegrammars.rb', line 143

def time_notrunc
  time_notrunc1 = seq(hour, minute, second, C::ZONE._?) do |(h, m, s, z)|
    h = { hour: h, min: m, sec: s }
    h[:zone] = z[0] unless z.empty?
    h
  end | seq(hour, minute, C::ZONE._?) do |(h, m, z)|
    h = { hour: h, min: m }
    h[:zone] = z[0] unless z.empty?
    h
  end | seq(hour, C::ZONE._?) do |(h, z)|
    h = { hour: h }
    h[:zone] = z[0] unless z.empty?
    h
  end
  time_notrunc = time_notrunc1.map { |d| PropertyValue::Time.new d }
  time_notrunc.eof
end

.time_tObject



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/vobject/vcard/v4_0/typegrammars.rb', line 109

def time_t
  hour = /[0-9]{2}/.r
  minute = /[0-9]{2}/.r
  second = /[0-9]{2}/.r
  time1 = seq(hour, minute, second, C::ZONE._?) do |(h, m, s, z)|
    h = { hour: h, min: m, sec: s }
    h[:zone] = z[0] unless z.empty?
    h
  end | seq(hour, minute, C::ZONE._?) do |(h, m, z)|
    h = { hour: h, min: m }
    h[:zone] = z[0] unless z.empty?
    h
  end | seq(hour, C::ZONE._?) do |(h, z)|
    h = { hour: h }
    h[:zone] = z[0] unless z.empty?
    h
    # } | seq("-", minute, second, C::ZONE._?) { |(m, s, z)|
    # errata: remove zones from truncated times
  end | seq("-".r >> minute, second) do |(m, s)|
    { min: m, sec: s }
    # } | seq("-", minute, C::ZONE._?) { |(m, z)|
    # errata: remove zones from truncated times
  end | seq("-".r >> minute) do |m|
    { min: m }
    # } | seq("-", "-", second, C::ZONE._?) do |(s, z)|
    # errata: remove zones from truncated times
  end | seq("-", "-", second) do |(_, _, s)|
    h = { sec: s }
    h
  end
  time = time1.map { |d| PropertyValue::Time.new d }
  time.eof
end

.timestampObject



202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'lib/vobject/vcard/v4_0/typegrammars.rb', line 202

def timestamp
  date_complete = seq(/[0-9]{4}/.r, /[0-9]{2}/.r, /[0-9]{2}/.r) do |(yy, mm, dd)|
    { year: yy, month: mm, day: dd }
  end
  hour = /[0-9]{2}/.r
  minute = /[0-9]{2}/.r
  second = /[0-9]{2}/.r
  time_complete = seq(hour, minute, second, C::ZONE._?) do |(h, m, s, z)|
    h = { hour: h, min: m, sec: s }
    h[:zone] = z[0] unless z.empty?
    h
  end
  timestamp = seq(date_complete << "T".r, time_complete) do |(d, t)|
    ret = PropertyValue::DateTimeLocal.new(d.merge(t))
    ret.type = 'timestamp'
    ret
  end
  timestamp.eof
end

.typematch(strict, key, params, _component, value) ⇒ Object

Enforce type restrictions on values of particular properties. If successful, return typed interpretation of string



414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
# File 'lib/vobject/vcard/v4_0/typegrammars.rb', line 414

def typematch(strict, key, params, _component, value)
  errors = []
  ctx1 = Rsec::ParseContext.new value, "source"
  case key
  when :VERSION
    ret = versionvalue._parse ctx1
  when :SOURCE, :PHOTO, :IMPP, :GEO, :LOGO, :MEMBER, :SOUND, :URL, :FBURL,
    :CALADRURI, :CALURI, :ORG_DIRECTORY
    ret = uri._parse ctx1
  when :KIND
    ret = kindvalue._parse ctx1
  when :XML, :FN, :EMAIL, :TITLE, :ROLE, :NOTE, :EXPERTISE, :HOBBY,
    :INTEREST
    ret = text_t._parse ctx1
  when :NICKNAME, :CATEGORIES
    ret = textlist._parse ctx1
  when :ORG
    ret = org._parse ctx1
  when :N
    ret = fivepartname._parse ctx1
  when :ADR
    ret = address._parse ctx1
  when :BDAY, :ANNIVERSARY
    if params && params[:VALUE] == "text"
      if params[:CALSCALE]
        parse_err(strict, errors,
                  "Specified CALSCALE within property #{key} as text", ctx1)
      end
      ret = text_t._parse ctx1
    else
      if params && params[:CALSCALE] && /^T/ =~ value
        parse_err(strict, errors,
                  "Specified CALSCALE within property #{key} as time", ctx1)
      end
      ret = date_and_or_time._parse ctx1
    end
  when :DEATHDATE
    ret = if params && params[:VALUE] == "text"
            text_t._parse ctx1
          else
            date_and_or_time._parse ctx1
          end
  when :TEL
    if params && params[:TYPE]
      typestr = params[:TYPE].is_a?(Array) ? params[:TYPE].join(",") : params[:TYPE]
      ret1 = typeparamtel1list.parse typestr
      if !ret1 || Rsec::INVALID[ret1]
        parse_err(strict, errors,
                  "Specified illegal TYPE parameter #{typestr} within property #{key}", ctx1)
      end
    end
    ret = if params && params[:VALUE] == "uri"
            uri._parse ctx1
          else
            text_t._parse ctx1
          end
  when :BIRTHPLACE, :DEATHPLACE
    ret = if params && params[:VALUE] == "uri"
            uri._parse ctx1
          else
            text_t._parse ctx1
          end
  when :RELATED
    if params && params[:TYPE]
      typestr = params[:TYPE].is_a?(Array) ? params[:TYPE].join(";") : params[:TYPE]
      ret1 = typerelatedlist.parse typestr
      if !ret1 || Rsec::INVALID[ret1]
        parse_err(strict, errors,
                  "Specified illegal TYPE parameter #{typestr} within property #{key}", ctx1)
      end
    end
    ret = if params && params[:VALUE] == "uri"
            uri._parse ctx1
          else
            text_t._parse ctx1
          end
  when :UID, :KEY
    ret = if params && params[:VALUE] == "text"
            text_t._parse ctx1
          else
            uri._parse ctx1
          end
  when :GENDER
    ret = gender._parse ctx1
  when :LANG
    ret = lang._parse ctx1
  when :TZ
    ret = if params && params[:VALUE] == "uri"
            uri._parse ctx1
          elsif params && params[:VALUE] == "utc_offset"
            utc_offset._parse ctx1
          else
            text_t._parse ctx1
          end
  when :REV
    ret = timestamp._parse ctx1
  when :CLIENTPIDMAP
    if params && params[:PID]
      parse_err(strict, errors, "Specified PID parameter in CLIENTPIDMAP property", @ctx)
    end
    ret = clientpidmap._parse ctx1
  else
    # left completely open in spec
    ret = Vobject::PropertyValue.new value
  end
  if ret.is_a?(Hash) && ret[:error]
    parse_err(strict, errors, "#{ret[:error]} for property #{key}, value #{value}", ctx1)
  end
  if Rsec::INVALID[ret]
    parse_err(strict, errors, "Type mismatch for property #{key}, value #{value}", ctx1)
  end
  ret
end

.typeparamtel1listObject



375
376
377
378
379
380
381
382
383
# File 'lib/vobject/vcard/v4_0/typegrammars.rb', line 375

def typeparamtel1list
  typeparamtel1 = /TEXT/i.r | /VOICE/i.r | /FAX/i.r | /CELL/i.r | /VIDEO/i.r |
    /PAGER/i.r | /TEXTPHONE/i.r | C::IANATOKEN | C::XNAME_VCARD
  typeparamtel1list = seq(typeparamtel1 << ",".r,
                          lazy { typeparamtel1list }) do |(a, b)|
    [a, b].flatten
  end | typeparamtel1.map { |t| [t] }
  typeparamtel1list.eof
end

.typerelatedlistObject



385
386
387
388
389
390
391
392
393
394
395
396
# File 'lib/vobject/vcard/v4_0/typegrammars.rb', line 385

def typerelatedlist
  typeparamrelated = /CONTACT/i.r | /ACQUAINTANCE/i.r | /FRIEND/i.r |
    /MET/i.r | /CO-WORKER/i.r | /COLLEAGUE/i.r | /CO-RESIDENT/i.r |
    /NEIGHBOR/i.r | /CHILD/i.r | /PARENT/i.r | /SIBLING/i.r | /SPOUSE/i.r |
    /KIN/i.r | /MUSE/i.r | /CRUSH/i.r | /DATE/i.r | /SWEETHEART/i.r |
    /ME/i.r | /AGENT/i.r | /EMERGENCY/i.r
  typerelatedlist =
    seq(typeparamrelated << ";".r,
        lazy { typerelatedlist }) { |(a, b)| [a, b].flatten } |
    typeparamrelated.map { |t| [t] }
  typerelatedlist.eof
end

.unescape(x) ⇒ Object

text escapes: \ ; , N n



399
400
401
402
403
# File 'lib/vobject/vcard/v4_0/typegrammars.rb', line 399

def unescape(x)
  # temporarily escape \\ as \007f, which is disallowed in any text
  x.gsub(/\\\\/, "\u007f").gsub(/\\,/, ",").gsub(/\\[Nn]/, "\n").
    tr("\u007f", "\\")
end

.unescape_component(x) ⇒ Object

also escape semicolon for compound types



406
407
408
409
410
# File 'lib/vobject/vcard/v4_0/typegrammars.rb', line 406

def unescape_component(x)
  # temporarily escape \\ as \007f, which is disallowed in any text
  x.gsub(/\\\\/, "\u007f").gsub(/\\;/, ";").gsub(/\\,/, ",").
    gsub(/\\[Nn]/, "\n").tr("\u007f", "\\")
end

.uriObject



33
34
35
36
37
38
39
40
41
42
# File 'lib/vobject/vcard/v4_0/typegrammars.rb', line 33

def uri
  uri = /\S+/.r.map do |s|
    if s =~ URI::DEFAULT_PARSER.make_regexp
      PropertyValue::Uri.new(s)
    else
      { error: "Invalid URI" }
    end
  end
  uri.eof
end

.utc_offsetObject



299
300
301
302
# File 'lib/vobject/vcard/v4_0/typegrammars.rb', line 299

def utc_offset
  utc_offset = C::UTC_OFFSET.map { |u| PropertyValue::Utcoffset.new u }
  utc_offset.eof
end

.versionvalueObject



28
29
30
31
# File 'lib/vobject/vcard/v4_0/typegrammars.rb', line 28

def versionvalue
  versionvalue = "4.0".r.map { |v| PropertyValue::Version.new v }
  versionvalue.eof
end