Class: Ecoportal::API::V2::Page::MouldCounter

Inherits:
Common::Content::DoubleModel show all
Defined in:
lib/ecoportal/api/v2/page/mould_counter.rb

Constant Summary collapse

UID_REGEX =
/^(?<prefix>.*?)(?<counter>\d+)(?<postfix>.*)$/i
STR_LEN =
5
BASE_NUM_STR =
"0" * STR_LEN

Constants included from Common::Content::DoubleModel::Diffable

Common::Content::DoubleModel::Diffable::DIFF_CLASS

Constants included from Common::Content::DoubleModel::Base

Common::Content::DoubleModel::Base::NOT_USED

Instance Attribute Summary

Attributes included from Common::Content::DoubleModel::Parented

#_parent, #_parent_key

Instance Method Summary collapse

Methods inherited from Common::Content::DoubleModel

#initialize, new_uuid

Methods included from Common::Content::DoubleModel::Diffable

#as_update, #dirty?

Methods included from Common::Content::Includer

#include_missing

Constructor Details

This class inherits a constructor from Ecoportal::API::Common::Content::DoubleModel

Instance Method Details

#set(uid) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/ecoportal/api/v2/page/mould_counter.rb', line 14

def set(uid)
  return nil unless uid.is_a?(String)
  return nil unless match = uid.match(UID_REGEX)
  self.counter = count_str(match[:counter])
  self.prefix = match[:prefix]
  self.postfix = match[:postfix]
  self.render = "#{match[:prefix]}#{counter}#{match[:postfix]}"
end