Class: QueenCheck::Arbitrary::Instance
- Inherits:
-
Object
- Object
- QueenCheck::Arbitrary::Instance
- Defined in:
- lib/queencheck/arbitrary.rb
Constant Summary collapse
- @@collection =
{}
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #arbitrary(seed) ⇒ Object
- #arbitrary? ⇒ Boolean
-
#initialize(name = nil, &block) ⇒ Instance
constructor
A new instance of Instance.
Constructor Details
#initialize(name = nil, &block) ⇒ Instance
Returns a new instance of Instance.
35 36 37 38 39 40 41 42 |
# File 'lib/queencheck/arbitrary.rb', line 35 def initialize(name = nil, &block) raise ArgumentError, "require block" if block.nil? @arbitrary_proc = block @name = name.to_s.to_sym unless name.nil? unless @name.nil? @@collection[@name] = self end end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
43 44 45 |
# File 'lib/queencheck/arbitrary.rb', line 43 def name @name end |
Class Method Details
.collection ⇒ Object
33 |
# File 'lib/queencheck/arbitrary.rb', line 33 def self.collection; @@collection; end |
.collection=(c) ⇒ Object
32 |
# File 'lib/queencheck/arbitrary.rb', line 32 def self.collection=(c); @@collection = c; end |
.get_by_id(name) ⇒ Object
31 |
# File 'lib/queencheck/arbitrary.rb', line 31 def self.get_by_id(name); return @@collection[name.to_s.to_sym]; end |
Instance Method Details
#arbitrary(seed) ⇒ Object
47 48 49 |
# File 'lib/queencheck/arbitrary.rb', line 47 def arbitrary(seed) @arbitrary_proc.call(seed) end |