method

screen_data_str

Importance_0
v1_8_6_287 - Show latest stable - 0 notes - Class: XSD::XSDDecimal
screen_data_str(str) private

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Hide source
# File lib/xsd/datatypes.rb, line 250
  def screen_data_str(str)
    /^([+\-]?)(\d*)(?:\.(\d*)?)?$/ =~ str.to_s.strip
    unless Regexp.last_match
      raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
    end
    sign = $1 || '+'
    int_part = $2
    frac_part = $3
    int_part = '0' if int_part.empty?
    frac_part = frac_part ? frac_part.sub(/0+$/, '') : ''
    point = - frac_part.size
    number = int_part + frac_part
    # normalize
    if sign == '+'
      sign = ''
    elsif sign == '-'
      if number == '0'
        sign = ''
      end
    end
    [sign, point, number]
  end
Register or log in to add new notes.