class Orgy::OrgTimeRange

OrgTimeRange

org-mode time ranges Contains two OrgTimeStamps and will print out as an org-mode date/time range.

Public Class Methods

new(date_one, date_two) click to toggle source

Requires two arguments. Argument one and two are the starting and ending dates respectively. Arguments must be kind of DateTime or Orgy::OrgTimeStamp

# File lib/orgy/org_timerange.rb, line 11
def initialize date_one, date_two

  if date_one.class != Orgy::OrgTimeStamp then
    if date_one.class != DateTime then
    raise ArgumentError, "Argument must be a kind of Orgy::OrgTimeStamp or DateTime"
    end
  end

  if date_two.class != Orgy::OrgTimeStamp then
    if date_two.class != DateTime then
      raise ArgumentError, "Argument must be a kind of Orgy::OrgTimeStamp or DateTime"
    end
  end

  if date_one.class == DateTime then
    date_one = Orgy::OrgTimeStamp.new date_one
  end

  if date_two.class == DateTime then
    date_two = Orgy::OrgTimeStamp.new date_two
  end

  @data = Hash.new
  @data[:starting_date] = date_one
  @data[:ending_date] = date_two
end

Public Instance Methods

active!() click to toggle source

Declares the range as active

# File lib/orgy/org_timerange.rb, line 44
def active!
  @data[:starting_date].active!
  @data[:ending_date].active!
end
active?() click to toggle source

Tests to see if the range is active

# File lib/orgy/org_timerange.rb, line 39
def active?
  @data[:starting_date].active? or @data[:ending_date].active?
end
inactive!() click to toggle source

Declares the range as inactive

# File lib/orgy/org_timerange.rb, line 50
def inactive!
  @data[:starting_date].inactive!
  @data[:ending_date].inactive!
end
to_s() click to toggle source

Prints range to string

# File lib/orgy/org_timerange.rb, line 56
def to_s
  if active? then active! else inactive! end                     
  @data[:starting_date].to_s << '--' << @data[:ending_date].to_s 
end