Module: Puppet::Pops::Types::PIntegerType::ClassModule
- Includes:
- Enumerable
- Defined in:
- lib/puppet/pops/types/types.rb
Instance Method Summary collapse
- #==(o) ⇒ Object
-
#each ⇒ Object
Returns Enumerator if no block is given Returns self if size is infinity (does not yield).
- #hash ⇒ Object
-
#range ⇒ Object
Returns the range as an array ordered so the smaller number is always first.
-
#size ⇒ Object
Returns Float.Infinity if one end of the range is unbound.
Instance Method Details
#==(o) ⇒ Object
135 136 137 |
# File 'lib/puppet/pops/types/types.rb', line 135 def ==(o) self.class == o.class && from == o.from && to == o.to end |
#each ⇒ Object
Returns Enumerator if no block is given Returns self if size is infinity (does not yield)
121 122 123 124 125 126 127 128 129 |
# File 'lib/puppet/pops/types/types.rb', line 121 def each return self.to_enum unless block_given? return nil if from.nil? || to.nil? if to < from from.downto(to) {|x| yield x } else from.upto(to) {|x| yield x } end end |
#hash ⇒ Object
131 132 133 |
# File 'lib/puppet/pops/types/types.rb', line 131 def hash [self.class, from, to].hash end |
#range ⇒ Object
Returns the range as an array ordered so the smaller number is always first. The number may be Infinity or -Infinity.
109 110 111 112 113 114 115 116 117 |
# File 'lib/puppet/pops/types/types.rb', line 109 def range f = from || NEGATIVE_INFINITY t = to || INFINITY if f < t [f, t] else [t,f] end end |