class Orgy::OrgTimeStamp
OrgTimeStamp
¶ ↑
org-mode time ranges OrgTimeStamp2will print out as an org-mode date/time.
Public Class Methods
new(date_time)
click to toggle source
# File lib/orgy/org_timestamp.rb, line 9 def initialize date_time if not date_time.class == DateTime then raise ArgumentError, "Argument must be a kind of DateTime" end @data = Hash.new @data[:date] = date_time @active = false @has_time = false @repeating = false @repeat = 'd' @repeat_interval = 1 end
Public Instance Methods
active!()
click to toggle source
# File lib/orgy/org_timestamp.rb, line 26 def active! @active = true end
active?()
click to toggle source
# File lib/orgy/org_timestamp.rb, line 22 def active? @active end
daily!()
click to toggle source
# File lib/orgy/org_timestamp.rb, line 50 def daily! @repeat = 'd' @repeating = true end
has_time?()
click to toggle source
# File lib/orgy/org_timestamp.rb, line 34 def has_time? @has_time end
inactive!()
click to toggle source
# File lib/orgy/org_timestamp.rb, line 30 def inactive! @active = false end
monthly!()
click to toggle source
# File lib/orgy/org_timestamp.rb, line 60 def monthly! @repeat = 'm' @repeating = true end
repeat_interval!(num=1)
click to toggle source
# File lib/orgy/org_timestamp.rb, line 70 def repeat_interval! num=1 if num.class != Fixnum and num.class != Integer then raise ArgumentError, "Repeat interval should be a integer value" end @repeat_interval = num end
repeating?()
click to toggle source
# File lib/orgy/org_timestamp.rb, line 42 def repeating? @repeating end
to_s()
click to toggle source
# File lib/orgy/org_timestamp.rb, line 77 def to_s date = @data[:date] str = "" if active? then str << '<' else str << '[' end str << date.strftime("%F %a") if has_time? then str << date.strftime(" %R") end if repeating? then str << ' +' << @repeat_interval.to_s << @repeat end if active? then str << '>' else str << ']' end str end
toggle_repeat!()
click to toggle source
# File lib/orgy/org_timestamp.rb, line 46 def toggle_repeat! @repeating = !@repeating end
toggle_time!()
click to toggle source
# File lib/orgy/org_timestamp.rb, line 38 def toggle_time! @has_time = !@has_time end
weekly!()
click to toggle source
# File lib/orgy/org_timestamp.rb, line 55 def weekly! @repeat = 'w' @repeating = true end
yearly!()
click to toggle source
# File lib/orgy/org_timestamp.rb, line 65 def yearly! @repeat = 'y' @repeating = true end