Class: Deimos::SchemaClass::Enum
- Defined in:
- lib/deimos/schema_class/enum.rb
Overview
Base Class for Enum Classes generated from Avro.
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Boolean
- #as_json(_opts = {}) ⇒ String
-
#initialize(value) ⇒ Enum
constructor
A new instance of Enum.
-
#symbols ⇒ Array<String>
Returns all the valid symbols for this enum.
- #to_s ⇒ String
Methods inherited from Base
Constructor Details
#initialize(value) ⇒ Enum
Returns a new instance of Enum.
26 27 28 |
# File 'lib/deimos/schema_class/enum.rb', line 26 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ String
12 13 14 |
# File 'lib/deimos/schema_class/enum.rb', line 12 def value @value end |
Class Method Details
.initialize_from_value(value) ⇒ SchemaClass::Enum
42 43 44 45 46 |
# File 'lib/deimos/schema_class/enum.rb', line 42 def self.initialize_from_value(value) return nil if value.nil? value.is_a?(self) ? value : self.new(value) end |
Instance Method Details
#==(other) ⇒ Boolean
16 17 18 |
# File 'lib/deimos/schema_class/enum.rb', line 16 def ==(other) other.is_a?(self.class) ? other.value == @value : other == @value end |
#as_json(_opts = {}) ⇒ String
37 38 39 |
# File 'lib/deimos/schema_class/enum.rb', line 37 def as_json(_opts={}) @value end |
#symbols ⇒ Array<String>
Returns all the valid symbols for this enum.
32 33 34 |
# File 'lib/deimos/schema_class/enum.rb', line 32 def symbols raise NotImplementedError end |
#to_s ⇒ String
21 22 23 |
# File 'lib/deimos/schema_class/enum.rb', line 21 def to_s @value.to_s end |