Class: Ice::FormatType
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
- #<=>(other) ⇒ Object
- #hash ⇒ Object
-
#initialize(val) ⇒ FormatType
constructor
A new instance of FormatType.
- #inspect ⇒ Object
- #to_i ⇒ Object
- #to_s ⇒ Object
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
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 |
#hash ⇒ Object
179 180 181 |
# File 'lib/Ice.rb', line 179 def hash @val.hash end |
#inspect ⇒ Object
183 184 185 |
# File 'lib/Ice.rb', line 183 def inspect @@_names[@val] + "(#{@val})" end |
#to_i ⇒ Object
170 171 172 |
# File 'lib/Ice.rb', line 170 def to_i @val end |
#to_s ⇒ Object
166 167 168 |
# File 'lib/Ice.rb', line 166 def to_s @@_names[@val] end |