Class: NewStoreApi::PeriodTypeEnum

Inherits:
Object
  • Object
show all
Defined in:
lib/new_store_api/models/period_type_enum.rb

Overview

Period of the report.

Constant Summary collapse

PERIOD_TYPE_ENUM =
[
  # TODO: Write general description for SHIFTREPORT
  SHIFTREPORT = 'shift-report'.freeze,

  # TODO: Write general description for DAYREPORT
  DAYREPORT = 'day-report'.freeze,

  # TODO: Write general description for MONTHREPORT
  MONTHREPORT = 'month-report'.freeze,

  # TODO: Write general description for YEARREPORT
  YEARREPORT = 'year-report'.freeze,

  # TODO: Write general description for GRANDTOTALSREPORT
  GRANDTOTALSREPORT = 'grand-totals-report'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = SHIFTREPORT) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/new_store_api/models/period_type_enum.rb', line 32

def self.from_value(value, default_value = SHIFTREPORT)
  return default_value if value.nil?

  str = value.to_s.strip

  case str.downcase
  when 'shiftreport' then SHIFTREPORT
  when 'dayreport' then DAYREPORT
  when 'monthreport' then MONTHREPORT
  when 'yearreport' then YEARREPORT
  when 'grandtotalsreport' then GRANDTOTALSREPORT
  else
    default_value
  end
end

.validate(value) ⇒ Object



26
27
28
29
30
# File 'lib/new_store_api/models/period_type_enum.rb', line 26

def self.validate(value)
  return false if value.nil?

  PERIOD_TYPE_ENUM.include?(value)
end