class Rubyfocus::ReviewPeriod

The ReviewPeriod represents a review period used with Projects in OmniFocus The ReviewPeriod is made up of three sections:

Constants

ALLOWED_UNITS

Attributes

size[RW]
unit[RW]

Public Class Methods

from_string(str) click to toggle source
# File lib/rubyfocus/review_period.rb, line 12
def self.from_string(str)
        if str =~ /^[@~]?(\d+)([a-z])$/
                size = $1.to_i
                unit = {"d" => :days, "w" => :weeks, "m" => :months, "y" => :years}[$2]
                new(size: size, unit: unit)
        else
                raise ArgumentError, "Unrecognised review period format: \"#{str}\"."
        end
end
new(size:0, unit: :months) click to toggle source
# File lib/rubyfocus/review_period.rb, line 22
def initialize(size:0, unit: :months)
        self.size = size
        self.unit = unit
end

Public Instance Methods

inspect()
Alias for: to_s
short_unit() click to toggle source
# File lib/rubyfocus/review_period.rb, line 33
def short_unit
        @short_unit ||= @unit.to_s[0]
end
to_s() click to toggle source
# File lib/rubyfocus/review_period.rb, line 37
def to_s
        "#{size}#{short_unit}"
end
Also aliased as: inspect, to_serial
to_serial()
Alias for: to_s
unit=(value) click to toggle source
# File lib/rubyfocus/review_period.rb, line 27
def unit= value
        raise ArgumentError, "Tried to set ReviewPeriod.unit to invalid value \"#{value}\"." unless ALLOWED_UNITS.include?(value)
        @unit = value
        @short_unit = nil
end