Sha256: c951e46ffe357fd333edab28d09f9a7ce81c552560bbb7db83b8b23f1367f3ed
Contents?: true
Size: 745 Bytes
Versions: 8
Compression:
Stored size: 745 Bytes
Contents
require "equalizer" module StudyEngine class StudyID def self.load slug return unless slug new slug end def self.dump study_id study_id.to_s end include Equalizer.new(:study, :site, :id) attr_accessor :study, :site, :id def initialize slug=nil @study, @site, @id = slug.split("-") if slug end def study= value @study = value.try(:upcase) end def site= value @site = value.try(:upcase) end def to_s [study, site, id].join("-") end def <=> other to_s <=> other.to_s end def present? [@study, @site, @id].all?(&:present?) end def valid? to_s =~ %r{\A[A-Z]{3}-[A-Z]{3}-[0-9]{4}\Z} end end end
Version data entries
8 entries across 8 versions & 1 rubygems