Class: Range
- Defined in:
- lib/puppet/util/zaml.rb,
lib/puppet/util/monkey_patches.rb
Direct Known Subclasses
Instance Method Summary collapse
Instance Method Details
#intersection(other) ⇒ Object Also known as: &
153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/puppet/util/monkey_patches.rb', line 153 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
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 |
# File 'lib/puppet/util/zaml.rb', line 403 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 |