Class: Ice::FormatType

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

Constant Summary collapse

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(val) ⇒ FormatType

Returns a new instance of FormatType.



156
157
158
159
# File 'lib/Ice.rb', line 156

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

Class Method Details

.each(&block) ⇒ Object



187
188
189
# File 'lib/Ice.rb', line 187

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

.from_int(val) ⇒ Object

Raises:

  • (IndexError)


161
162
163
164
# File 'lib/Ice.rb', line 161

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

Instance Method Details

#<=>(other) ⇒ Object



174
175
176
177
# File 'lib/Ice.rb', line 174

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

#hashObject



179
180
181
# File 'lib/Ice.rb', line 179

def hash
    @val.hash
end

#inspectObject



183
184
185
# File 'lib/Ice.rb', line 183

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

#to_iObject



170
171
172
# File 'lib/Ice.rb', line 170

def to_i
    @val
end

#to_sObject



166
167
168
# File 'lib/Ice.rb', line 166

def to_s
    @@_names[@val]
end