class Range

Public Instance Methods

&(other)
Alias for: intersection
intersection(other) click to toggle source
# File lib/puppet/util/monkey_patches.rb, line 206
def intersection(other)
  raise ArgumentError, 'value must be a Range' unless other.kind_of?(Range)
  return unless other === self.first || self === other.first

  start = [self.first, other.first].max
  if self.exclude_end? && self.last <= other.last
    start ... self.last
  elsif other.exclude_end? && self.last >= other.last
    start ... other.last
  else
    start .. [ self.last, other.last ].min
  end
end
Also aliased as: &
to_zaml(z) click to toggle source
# File lib/puppet/util/zaml.rb, line 390
def to_zaml(z)
  z.first_time_only(self) {
    z.emit(zamlized_class_name(Range))
    z.nested {
      z.nl
      z.emit('begin: ')
      z.emit(first)
      z.nl
      z.emit('end: ')
      z.emit(last)
      z.nl
      z.emit('excl: ')
      z.emit(exclude_end?)
    }
  }
end