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, ULong, ULongLong, UShort

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:



480
481
482
# File 'lib/ridl/type.rb', line 480

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

#maxObject



477
478
479
# File 'lib/ridl/type.rb', line 477

def max
  @node.enumerators.length-1
end

#minObject



474
475
476
# File 'lib/ridl/type.rb', line 474

def min
  0
end

#narrow(obj) ⇒ Object



466
467
468
469
470
# File 'lib/ridl/type.rb', line 466

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

#next(val) ⇒ Object



483
484
485
# File 'lib/ridl/type.rb', line 483

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

#range_lengthObject



471
472
473
# File 'lib/ridl/type.rb', line 471

def range_length
  @node.enumerators.length
end