Class: Deimos::SchemaClass::Enum

Inherits:
Base
  • Object
show all
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

Methods inherited from Base

#[]=, #inspect

Constructor Details

#initialize(value) ⇒ Enum

Returns a new instance of Enum.

Parameters:

  • value (String)


24
25
26
# File 'lib/deimos/schema_class/enum.rb', line 24

def initialize(value)
  @value = value
end

Instance Attribute Details

#valueObject

Returns the value of attribute value.



11
12
13
# File 'lib/deimos/schema_class/enum.rb', line 11

def value
  @value
end

Class Method Details

.initialize_from_value(value) ⇒ Object

:nodoc:



40
41
42
43
44
# File 'lib/deimos/schema_class/enum.rb', line 40

def self.initialize_from_value(value)
  return nil if value.nil?

  value.is_a?(self) ? value : self.new(value)
end

Instance Method Details

#==(other) ⇒ Object

Parameters:



14
15
16
# File 'lib/deimos/schema_class/enum.rb', line 14

def ==(other)
  other.is_a?(self.class) ? other.value == @value : other == @value
end

#as_json(_opts = {}) ⇒ Object

:nodoc:



35
36
37
# File 'lib/deimos/schema_class/enum.rb', line 35

def as_json(_opts={})
  @value
end

#symbolsArray<String>

Returns all the valid symbols for this enum.

Returns:

  • (Array<String>)

Raises:

  • (NotImplementedError)


30
31
32
# File 'lib/deimos/schema_class/enum.rb', line 30

def symbols
  raise NotImplementedError
end

#to_sString

Returns:

  • (String)


19
20
21
# File 'lib/deimos/schema_class/enum.rb', line 19

def to_s
  @value.to_s
end