Files

Class Index [+]

Quicksearch

XSD::XSDDuration

Constants

Type

Attributes

sign[RW]
year[RW]
month[RW]
day[RW]
hour[RW]
min[RW]
sec[RW]

Public Class Methods

new(value = nil) click to toggle source
     # File lib/xsd/datatypes.rb, line 447
447:   def initialize(value = nil)
448:     init(Type, value)
449:   end

Private Instance Methods

_set(data) click to toggle source
     # File lib/xsd/datatypes.rb, line 472
472:   def _set(data)
473:     if data.nil?
474:       @sign = @year = @month = @day = @hour = @min = @sec = @data = nil
475:       return
476:     end
477:     @sign, @year, @month, @day, @hour, @min, @sec = data
478:     @data = _to_s
479:     @data.freeze
480:   end
_to_s() click to toggle source
     # File lib/xsd/datatypes.rb, line 482
482:   def _to_s
483:     str = ''
484:     str << @sign if @sign
485:     str << 'P'
486:     l = ''
487:     l << "#{ @year }Y" if @year.nonzero?
488:     l << "#{ @month }M" if @month.nonzero?
489:     l << "#{ @day }D" if @day.nonzero?
490:     r = ''
491:     r << "#{ @hour }H" if @hour.nonzero?
492:     r << "#{ @min }M" if @min.nonzero?
493:     r << "#{ @sec }S" if @sec.nonzero?
494:     str << l
495:     unless r.empty?
496:       str << "T" << r
497:     end
498:     if l.empty? and r.empty?
499:       str << "0D"
500:     end
501:     str
502:   end
screen_data(value) click to toggle source
     # File lib/xsd/datatypes.rb, line 453
453:   def screen_data(value)
454:     /^([+\-]?)P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)D)?(T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?)?$/ =~ value.to_s.strip
455:     unless Regexp.last_match
456:       raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
457:     end
458:     if $5 and !$6 and !$7 and !$8
459:       # allows durations lower than a day such as 'PT5S'.
460:       raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
461:     end
462:     sign = $1
463:     year = $2.to_i
464:     month = $3.to_i
465:     day = $4.to_i
466:     hour = $6.to_i
467:     min = $7.to_i
468:     sec = $8 ? XSDDecimal.new($8) : 0
469:     [sign, year, month, day, hour, min, sec]
470:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.