2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2017-08-14 11:56:23 +00:00
|
|
|
class Sequencer
|
2017-09-01 12:28:06 +00:00
|
|
|
class Units < SimpleDelegator
|
2017-08-14 11:56:23 +00:00
|
|
|
class Attribute
|
|
|
|
|
2020-03-18 09:56:37 +00:00
|
|
|
attr_accessor :from, :to, :optional
|
2017-08-14 11:56:23 +00:00
|
|
|
|
|
|
|
# Checks if the attribute will be provided by one or more Units.
|
|
|
|
#
|
|
|
|
# @example
|
|
|
|
# attribute.will_be_provided?
|
|
|
|
# # => true
|
|
|
|
#
|
|
|
|
# @return [Boolean]
|
|
|
|
def will_be_provided?
|
|
|
|
!from.nil?
|
|
|
|
end
|
|
|
|
|
|
|
|
# Checks if the attribute will be used by one or more Units.
|
|
|
|
#
|
|
|
|
# @example
|
|
|
|
# attribute.will_be_used?
|
|
|
|
# # => true
|
|
|
|
#
|
|
|
|
# @return [Boolean]
|
|
|
|
def will_be_used?
|
2020-03-18 09:56:37 +00:00
|
|
|
till.present?
|
|
|
|
end
|
|
|
|
|
|
|
|
def optional?
|
|
|
|
to.nil? && !optional.nil?
|
|
|
|
end
|
|
|
|
|
|
|
|
def cleanup?(index)
|
|
|
|
return true if !will_be_used?
|
|
|
|
|
|
|
|
till <= index
|
|
|
|
end
|
|
|
|
|
|
|
|
def available?(index)
|
|
|
|
index.between?(from, till)
|
|
|
|
end
|
|
|
|
|
|
|
|
def till
|
|
|
|
[to, optional].compact.max
|
2017-08-14 11:56:23 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|