Files

Class Index [+]

Quicksearch

XSD::XSDDecimal

Constants

Type

Public Class Methods

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

Public Instance Methods

nonzero?() click to toggle source
     # File lib/xsd/datatypes.rb, line 250
250:   def nonzero?
251:     (@number != '0')
252:   end

Private Instance Methods

_set(data) click to toggle source
     # File lib/xsd/datatypes.rb, line 287
287:   def _set(data)
288:     if data.nil?
289:       @sign = @point = @number = @data = nil
290:       return
291:     end
292:     @sign, @point, @number = data
293:     @data = _to_s
294:     @data.freeze
295:   end
_to_s() click to toggle source

0.0 -> 0; right?

     # File lib/xsd/datatypes.rb, line 298
298:   def _to_s
299:     str = @number.dup
300:     if @point.nonzero?
301:       str[@number.size + @point, 0] = '.'
302:     end
303:     @sign + str
304:   end
screen_data(d) click to toggle source
     # File lib/xsd/datatypes.rb, line 256
256:   def screen_data(d)
257:     if d.is_a?(String)
258:       # Integer("00012") => 10 in Ruby.
259:       d.sub!(/^([+\-]?)0*(?=\d)/, "\\1")
260:     end
261:     screen_data_str(d)
262:   end
screen_data_str(str) click to toggle source
     # File lib/xsd/datatypes.rb, line 264
264:   def screen_data_str(str)
265:     /^([+\-]?)(\d*)(?:\.(\d*)?)?$/ =~ str.to_s.strip
266:     unless Regexp.last_match
267:       raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
268:     end
269:     sign = $1 || '+'
270:     int_part = $2
271:     frac_part = $3
272:     int_part = '0' if int_part.empty?
273:     frac_part = frac_part ? frac_part.sub(/0+$/, '') : ''
274:     point = - frac_part.size
275:     number = int_part + frac_part
276:     # normalize
277:     if sign == '+'
278:       sign = ''
279:     elsif sign == '-'
280:       if number == '0'
281:         sign = ''
282:       end
283:     end
284:     [sign, point, number]
285:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.