lib/vcard.rb in vcard-0.2.0 vs lib/vcard.rb in vcard-0.2.1
- old
+ new
@@ -1,10 +1,10 @@
# Copyright (C) 2008 Sam Roberts
# This library is free software; you can redistribute it and/or modify
# it under the same terms as the ruby language itself, see the file
-# LICENSE-VPIM.txt for details.
+# VPIM-LICENSE.txt for details.
require "date"
require "open-uri"
require "stringio"
@@ -53,11 +53,11 @@
end
# Convert a RFC 2425 date into an array of [year, month, day].
def self.decode_date(v) # :nodoc:
unless v =~ %r{^\s*#{Bnf::DATE}\s*$}
- raise Vcard::InvalidEncodingError, "date not valid (#{v})"
+ raise ::Vcard::InvalidEncodingError, "date not valid (#{v})"
end
[$1.to_i, $2.to_i, $3.to_i]
end
# Convert a RFC 2425 date into a Date object.
@@ -84,11 +84,11 @@
end
# Convert a RFC 2425 time into an array of [hour,min,sec,secfrac,timezone]
def self.decode_time(v) # :nodoc:
unless match = %r{^\s*#{Bnf::TIME}\s*$}.match(v)
- raise Vcard::InvalidEncodingError, "time '#{v}' not valid"
+ raise ::Vcard::InvalidEncodingError, "time '#{v}' not valid"
end
hour, min, sec, secfrac, tz = match.to_a[1..5]
[hour.to_i, min.to_i, sec.to_i, secfrac ? secfrac.to_f : 0, tz]
end
@@ -97,11 +97,11 @@
# We get [ year, month, day, hour, min, sec, usec, tz ]
begin
tz = (dtarray.pop == "Z") ? :gm : :local
Time.send(tz, *dtarray)
rescue ArgumentError => e
- raise Vcard::InvalidEncodingError, "#{tz} #{e} (#{dtarray.join(', ')})"
+ raise ::Vcard::InvalidEncodingError, "#{tz} #{e} (#{dtarray.join(', ')})"
end
end
# Convert a RFC 2425 time into an array of Time objects.
def self.decode_time_to_time(v) # :nodoc:
@@ -109,11 +109,11 @@
end
# Convert a RFC 2425 date-time into an array of [year,mon,day,hour,min,sec,secfrac,timezone]
def self.decode_date_time(v) # :nodoc:
unless match = %r{^\s*#{Bnf::DATE}T#{Bnf::TIME}\s*$}.match(v)
- raise Vcard::InvalidEncodingError, "date-time '#{v}' not valid"
+ raise ::Vcard::InvalidEncodingError, "date-time '#{v}' not valid"
end
year, month, day, hour, min, sec, secfrac, tz = match.to_a[1..8]
[
# date
@@ -136,11 +136,11 @@
# float_list
# Convert an RFC2425 INTEGER value into an Integer
def self.decode_integer(v) # :nodoc:
unless %r{\s*#{Bnf::INTEGER}\s*}.match(v)
- raise Vcard::InvalidEncodingError, "integer not valid (#{v})"
+ raise ::Vcard::InvalidEncodingError, "integer not valid (#{v})"
end
v.to_i
end
#
@@ -229,21 +229,21 @@
def self.encode_paramtext(value)
case value
when %r{\A#{Bnf::SAFECHAR}*\z}
value
else
- raise Vcard::Unencodable, "paramtext #{value.inspect}"
+ raise ::Vcard::Unencodable, "paramtext #{value.inspect}"
end
end
def self.encode_paramvalue(value)
case value
when %r{\A#{Bnf::SAFECHAR}*\z}
value
when %r{\A#{Bnf::QSAFECHAR}*\z}
'"' + value + '"'
else
- raise Vcard::Unencodable, "param-value #{value.inspect}"
+ raise ::Vcard::Unencodable, "param-value #{value.inspect}"
end
end
# Unfold the lines in +card+, then return an array of one Field object per