Class: Enumeration

Inherits:
Object
  • Object
show all
Defined in:
lib/voruby/misc.rb,
lib/misc/misc.rb

Overview

An abstract class that represents a set of possible choices.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(v) ⇒ Enumeration

Returns a new instance of Enumeration.



29
30
31
32
# File 'lib/misc/misc.rb', line 29

def initialize(choices, value)
  @choices = choices
  self.value = value
end

Instance Attribute Details

#choicesObject (readonly)

Returns the value of attribute choices.



27
28
29
# File 'lib/misc/misc.rb', line 27

def choices
  @choices
end

#valueObject

Returns the value of attribute value.



27
28
29
# File 'lib/misc/misc.rb', line 27

def value
  @value
end

Class Method Details

.choicesObject



100
# File 'lib/voruby/misc.rb', line 100

def self.choices; nil end

Instance Method Details

#==(v) ⇒ Object



39
40
41
42
# File 'lib/misc/misc.rb', line 39

def ==(obj)
  return false if !obj.is_a?(self.class)
  self.value == obj.value
end

#to_sObject



116
117
118
# File 'lib/voruby/misc.rb', line 116

def to_s
  self.value.to_s
end