class OpenEHR::AssumedLibraryTypes::Interval

Attributes

lower[R]
upper[R]

Public Class Methods

new(args = {}) click to toggle source
# File lib/openehr/assumed_library_types.rb, line 14
def initialize(args = {})
  check_lower_upper(args[:lower], args[:upper])
  self.lower_included = args[:lower_included]
  self.upper_included = args[:upper_included]
end

Public Instance Methods

==(value) click to toggle source
# File lib/openehr/assumed_library_types.rb, line 69
def ==(value)
  return (@lower == value.lower) && (@upper == value.upper) &&
    (@lower_included == value.lower_included?) &&
      (@upper_included == value.upper_included?)
end
has?(value) click to toggle source
# File lib/openehr/assumed_library_types.rb, line 60
def has?(value)
  if ((@lower.nil?||@lower < value||((@lower_included == true) && (@lower == value)))&&
      (@upper.nil?||value < @upper||((@upper_included == true) && (@upper == value))))
    true
  else
    false
  end
end
lower=(lower) click to toggle source
# File lib/openehr/assumed_library_types.rb, line 20
def lower=(lower)
  check_lower_upper(lower, @upper)
end
lower_included=(lower_included) click to toggle source
# File lib/openehr/assumed_library_types.rb, line 32
def lower_included=(lower_included)
  if (lower.nil?) && (!lower_included.nil?)
    raise ArgumentError, "lower is not set"
  end
  lower_included = true if !lower.nil? && lower_included.nil?
  @lower_included = lower_included
end
lower_included?() click to toggle source
# File lib/openehr/assumed_library_types.rb, line 28
def lower_included?
  return @lower_included
end
lower_unbounded?() click to toggle source
# File lib/openehr/assumed_library_types.rb, line 40
def lower_unbounded?
  return @lower.nil?
end
upper=(upper) click to toggle source
# File lib/openehr/assumed_library_types.rb, line 24
def upper=(upper)
  check_lower_upper(@lower, upper)
end
upper_included=(upper_included) click to toggle source
# File lib/openehr/assumed_library_types.rb, line 48
def upper_included=(upper_included)
  if (@upper.nil?) && (upper_included != nil)
    raise ArgumentError, "upper is not set"
  end
  upper_included = true if !upper.nil? && upper_included.nil?
  @upper_included = upper_included
end
upper_included?() click to toggle source
# File lib/openehr/assumed_library_types.rb, line 44
def upper_included?
  return @upper_included
end
upper_unbounded?() click to toggle source
# File lib/openehr/assumed_library_types.rb, line 56
def upper_unbounded?
  return @upper.nil?
end

Private Instance Methods

check_lower_upper(lower, upper) click to toggle source
# File lib/openehr/assumed_library_types.rb, line 76
def check_lower_upper(lower, upper)
  if lower.nil? && upper.nil?
    raise ArgumentError, "Either lower or upper must be assigned"
  end
  unless (lower.nil? || upper.nil?)
    if lower > upper
      raise ArgumentError, "Upper must be larger than lower."
    end
  end
  @lower = lower
  @upper = upper
end