Class: R2CORBA::CORBA::TypeCode::Fixed

Inherits:
R2CORBA::CORBA::TypeCode show all
Defined in:
lib/corba/cbase/Typecode.rb,
lib/corba/jbase/Typecode.rb,
lib/corba/common/Typecode.rb

Overview

WString

Constant Summary

Constants inherited from R2CORBA::CORBA::TypeCode

LongLongRange, LongRange, OctetRange, ShortRange, ULongLongRange, ULongRange, UShortRange

Instance Attribute Summary

Attributes inherited from R2CORBA::CORBA::TypeCode

#tc_

Instance Method Summary collapse

Methods inherited from R2CORBA::CORBA::TypeCode

_tc, _wrap_native, #concrete_base_type, #content_type, #default_index, #discriminator_type, #equal?, #equivalent?, #fixed_digits, #fixed_scale, from_native, #get_compact_typecode, get_primitive_tc, #id, #is_recursive_tc?, #kind, #length, #member_count, #member_label, #member_name, #member_type, #member_visibility, #name, native_kind, register_id_type, #resolved_tc, #type_modifier, typecode_for_id, typecodes_for_name

Constructor Details

#initialize(*args) ⇒ Fixed

Returns a new instance of Fixed.

Raises:

  • (RuntimeError)


80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/corba/cbase/Typecode.rb', line 80

def initialize(*args)
  if CORBA::Native::TypeCode === args.first
    @tc_ = args.first
  else
    digits, scale = args
    begin
      @tc_ = CORBA::Native::TypeCode.create_tc(TK_FIXED, digits.to_i, scale.to_i)
    rescue ::NativeException
      CORBA::Exception.native2r($!)
    end
  end
end

Instance Method Details

#get_typeObject



496
497
498
# File 'lib/corba/common/Typecode.rb', line 496

def get_type
  ::BigDecimal
end

#needs_conversion(val) ⇒ Object



507
508
509
# File 'lib/corba/common/Typecode.rb', line 507

def needs_conversion(val)
  !(::BigDecimal === val)
end

#validate(val) ⇒ Object



500
501
502
503
504
505
# File 'lib/corba/common/Typecode.rb', line 500

def validate(val)
  return val if val.nil?
  super(val) unless ::BigDecimal === val || val.respond_to?(:to_str)
  val = ::BigDecimal === val ? val : BigDecimal.new(val.to_str)
  val
end