Class: RspecPuppetFactsUnsupported::Randomizer
- Inherits:
-
Object
- Object
- RspecPuppetFactsUnsupported::Randomizer
- Defined in:
- lib/rspec-puppet-facts-unsupported/on_unsupported_os.rb
Overview
Private class to perform randomization
Instance Attribute Summary collapse
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#seed ⇒ Object
readonly
Returns the value of attribute seed.
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(opts, envkey = :RSPEC_PUPPET_FACTS_UNSUPPORTED_ORDER) ⇒ Randomizer
constructor
A new instance of Randomizer.
- #should_randomize? ⇒ Boolean
Constructor Details
#initialize(opts, envkey = :RSPEC_PUPPET_FACTS_UNSUPPORTED_ORDER) ⇒ Randomizer
Returns a new instance of Randomizer.
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/rspec-puppet-facts-unsupported/on_unsupported_os.rb', line 71 def initialize(opts, envkey = :RSPEC_PUPPET_FACTS_UNSUPPORTED_ORDER) opts[:order] ||= :random randomize_seed envvar = ENV[envkey.to_s] ordervalue = envvar.nil? ? opts[:order] : envvar.to_sym ilike = Integerlike.new(ordervalue) self.seed = ilike.to_i if ilike.integer? @order = ordervalue @repetitive_random = Random.new(42) end |
Instance Attribute Details
#order ⇒ Object (readonly)
Returns the value of attribute order.
69 70 71 |
# File 'lib/rspec-puppet-facts-unsupported/on_unsupported_os.rb', line 69 def order @order end |
#seed ⇒ Object
Returns the value of attribute seed.
69 70 71 |
# File 'lib/rspec-puppet-facts-unsupported/on_unsupported_os.rb', line 69 def seed @seed end |
Instance Method Details
#get ⇒ Object
82 83 84 |
# File 'lib/rspec-puppet-facts-unsupported/on_unsupported_os.rb', line 82 def get should_randomize? ? @randomizer : @repetitive_random end |
#should_randomize? ⇒ Boolean
86 87 88 |
# File 'lib/rspec-puppet-facts-unsupported/on_unsupported_os.rb', line 86 def should_randomize? @order == :random || Integerlike.new(@order).integer? end |