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)


26
27
28
# File 'lib/deimos/schema_class/enum.rb', line 26

def initialize(value)
  @value = value
end

Instance Attribute Details

#valueString

Returns:

  • (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

Returns:



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

Parameters:

Returns:

  • (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

Returns:

  • (String)


37
38
39
# File 'lib/deimos/schema_class/enum.rb', line 37

def as_json(_opts={})
  @value
end

#symbolsArray<String>

Returns all the valid symbols for this enum.

Returns:

  • (Array<String>)

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/deimos/schema_class/enum.rb', line 32

def symbols
  raise NotImplementedError
end

#to_sString

Returns:

  • (String)


21
22
23
# File 'lib/deimos/schema_class/enum.rb', line 21

def to_s
  @value.to_s
end