Class: IDL::Type::Enum

Inherits:
NodeType show all
Defined in:
lib/ridl/type.rb

Constant Summary

Constants inherited from IDL::Type

Long, LongLong, Octet, Short, TinyShort, ULong, ULongLong, UShort, UTinyShort

Instance Attribute Summary

Attributes inherited from NodeType

#node

Instance Method Summary collapse

Methods inherited from NodeType

#initialize, #is_local?, #is_node?, #matches?, #resolved_node

Methods inherited from IDL::Type

#instantiate, #is_anonymous?, #is_complete?, #is_local?, #is_node?, #is_template?, #matches?, #resolved_node, #resolved_type, #typeerror, #typename

Constructor Details

This class inherits a constructor from IDL::Type::NodeType

Instance Method Details

#in_range?(val) ⇒ Boolean

Returns:



649
650
651
# File 'lib/ridl/type.rb', line 649

def in_range?(val)
  val >= self.min && val <= self.max
end

#maxObject



645
646
647
# File 'lib/ridl/type.rb', line 645

def max
  @node.enumerators.length - 1
end

#minObject



641
642
643
# File 'lib/ridl/type.rb', line 641

def min
  0
end

#narrow(obj) ⇒ Object



631
632
633
634
635
# File 'lib/ridl/type.rb', line 631

def narrow(obj)
  typeerror(obj) unless ::Integer === obj
  typeerror(obj) unless (0...@node.enumerators.length) === obj
  obj
end

#next(val) ⇒ Object



653
654
655
# File 'lib/ridl/type.rb', line 653

def next(val)
  val < self.max ? val + 1 : self.min
end

#range_lengthObject



637
638
639
# File 'lib/ridl/type.rb', line 637

def range_length
  @node.enumerators.length
end