Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

Changeset 99

Show
Ignore:
Timestamp:
05/24/01 22:33:12 (7 years ago)
Author:
nakahiro
Message:

Extracted literals from code.
Added NaN, INF, -INF support of Float type.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/soap/XMLSchemaDatatypes.rb

    r84 r99  
    2323  Namespace = 'http://www.w3.org/2001/XMLSchema' 
    2424  InstanceNamespace = 'http://www.w3.org/2001/XMLSchema-instance' 
     25 
     26  AnyTypeLiteral = 'anyType' 
    2527  NilLiteral = 'nil' 
    26   #Namespace = 'http://www.w3.org/1999/XMLSchema' 
    27   #InstanceNamespace = 'http://www.w3.org/1999/XMLSchema-instance' 
    28   #NilLiteral = 'null' 
     28  BooleanLiteral = 'boolean' 
     29  StringLiteral = 'string' 
     30  FloatLiteral = 'float' 
     31  DateTimeLiteral = 'dateTime' 
     32  Base64BinaryLiteral = 'base64Binary' 
     33  IntegerLiteral = 'integer' 
     34  IntLiteral = 'int' 
     35 
     36  # for xsd:1999 
     37  # Namespace = 'http://www.w3.org/1999/XMLSchema' 
     38  # InstanceNamespace = 'http://www.w3.org/1999/XMLSchema-instance' 
     39  # AnyTypeLiteral = 'ur-type' 
     40  # NilLiteral = 'null' 
     41  # DateTimeLiteral = 'timeInstant' 
    2942end 
    3043 
     
    8093 
    8194  def initialize( initBoolean = false ) 
    82     super( 'boolean'
     95    super( BooleanLiteral
    8396    set( initBoolean ) 
    8497  end 
     
    101114 
    102115  def initialize( initString = nil ) 
    103     super( 'string'
     116    super( StringLiteral
    104117    set( initString ) if initString 
    105118  end 
     
    127140 
    128141  def initialize( initFloat = nil ) 
    129     super( 'float'
     142    super( FloatLiteral
    130143    set( initFloat ) if initFloat 
    131144  end 
    132145 
    133146  def set( newFloat ) 
    134     @data = newFloat.to_f 
     147    unless newFloat.is_a?( Float ) 
     148      # to_f understands 'NaN', 'INF', and '-INF' 
     149      @data = newFloat.to_f 
     150    else 
     151      @data = newFloat 
     152    end 
     153  end 
     154 
     155  # Do I have to convert 0.0 -> 0 and -0.0 -> -0 ? 
     156  def to_s 
     157    if @data.nan? 
     158      'NaN' 
     159    elsif @data.infinite? == 1 
     160      'INF' 
     161    elsif @data.infinite? == -1 
     162      '-INF' 
     163    else 
     164      @data.to_s 
     165    end 
    135166  end 
    136167end 
     
    143174 
    144175  def initialize( initDateTime = nil ) 
    145     super( 'dateTime'
     176    super( DateTimeLiteral
    146177    set( initDateTime ) if initDateTime 
    147178  end 
     
    158189        $stderr.puts "Timezone in String is not supported.  Set a Date or a Time directly!" 
    159190      end 
    160       @data = Date.new3( year, mon, mday, hour, min
     191      @data = Date.new3( year, mon, mday, hour, min, sec
    161192    end 
    162193  end 
     
    172203  # String in Ruby could be a binary. 
    173204  def initialize( initString = nil ) 
    174     super( 'base64Binary'
     205    super( Base64BinaryLiteral
    175206    set( initString ) if initString 
    176207  end 
     
    184215  end 
    185216 
    186   def to_s 
     217  def toString 
    187218    @data.unpack( "m" )[ 0 ] 
    188219  end 
     
    198229  def initialize( initInteger = nil ) 
    199230    super() 
    200     @typeName = 'integer' 
     231    @typeName = IntegerLiteral 
    201232    set( initInteger ) if initInteger 
    202233  end 
     
    212243  def initialize( initInt = nil ) 
    213244    super() 
    214     @typeName = 'int' 
     245    @typeName = IntLiteral 
    215246    set( initInt ) if initInt 
    216247  end