Class: Ice::FormatType

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
ruby/Ice/Value.rb

Overview

The marshaling format for class instances.

Constant Summary collapse

CompactFormat =
SlicedFormat =
@@_names =
['CompactFormat', 'SlicedFormat']
@@_values =
[FormatType.new(0), FormatType.new(1)]

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(val) ⇒ FormatType

Returns a new instance of FormatType.



50
51
52
53
# File 'ruby/Ice/Value.rb', line 50

def initialize(val)
    fail("invalid value #{val} for FormatType") unless(val >= 0 and val < 2)
    @val = val
end

Class Method Details

.each(&block) ⇒ Object



81
82
83
# File 'ruby/Ice/Value.rb', line 81

def FormatType.each(&block)
    @@_values.each(&block)
end

.from_int(val) ⇒ Object

Raises:

  • (IndexError)


55
56
57
58
# File 'ruby/Ice/Value.rb', line 55

def FormatType.from_int(val)
    raise IndexError, "#{val} is out of range 0..1" if(val < 0 || val > 1)
    @@_values[val]
end

Instance Method Details

#<=>(other) ⇒ Object



68
69
70
71
# File 'ruby/Ice/Value.rb', line 68

def <=>(other)
    other.is_a?(FormatType) or raise ArgumentError, "value must be a FormatType"
    @val <=> other.to_i
end

#hashObject



73
74
75
# File 'ruby/Ice/Value.rb', line 73

def hash
    @val.hash
end

#inspectObject



77
78
79
# File 'ruby/Ice/Value.rb', line 77

def inspect
    @@_names[@val] + "(#{@val})"
end

#to_iObject



64
65
66
# File 'ruby/Ice/Value.rb', line 64

def to_i
    @val
end

#to_sObject



60
61
62
# File 'ruby/Ice/Value.rb', line 60

def to_s
    @@_names[@val]
end