Class: Range
- Defined in:
- lib/vendor/puppet/util/zaml.rb,
lib/vendor/puppet/util/monkey_patches.rb
Instance Method Summary collapse
Instance Method Details
#intersection(other) ⇒ Object Also known as: &
181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/vendor/puppet/util/monkey_patches.rb', line 181 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 |
#to_zaml(z) ⇒ Object
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 |
# File 'lib/vendor/puppet/util/zaml.rb', line 391 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 |