Sha256: 1c848b1bd98f94f3af96fe2d756e0e0a131a5b712fab6d4a9a35c3b8fc13ee56
Contents?: true
Size: 914 Bytes
Versions: 6
Compression:
Stored size: 914 Bytes
Contents
module Ecoportal module API class V2 class Page class MouldCounter < Ecoportal::API::Common::Content::DoubleModel UID_REGEX = /^(?<prefix>.*?)(?<counter>\d+)(?<postfix>.*)$/i STR_LEN = 5 BASE_NUM_STR = "0" * STR_LEN passthrough :prefix, :postfix passthrough :counter passthrough :render 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 private def count_str(num) (BASE_NUM_STR + num.to_s)[-5..-1] end end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems