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.



195
196
197
198
# File 'lib/Ice.rb', line 195

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

Class Method Details

.each(&block) ⇒ Object



226
227
228
# File 'lib/Ice.rb', line 226

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

.from_int(val) ⇒ Object

Raises:

  • (IndexError)


200
201
202
203
# File 'lib/Ice.rb', line 200

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



213
214
215
216
# File 'lib/Ice.rb', line 213

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

#hashObject



218
219
220
# File 'lib/Ice.rb', line 218

def hash
    @val.hash
end

#inspectObject



222
223
224
# File 'lib/Ice.rb', line 222

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

#to_iObject



209
210
211
# File 'lib/Ice.rb', line 209

def to_i
    @val
end

#to_sObject



205
206
207
# File 'lib/Ice.rb', line 205

def to_s
    @@_names[@val]
end