Class: QueenCheck::Arbitrary::Instance

Inherits:
Object
  • Object
show all
Defined in:
lib/queencheck/arbitrary.rb

Constant Summary collapse

@@collection =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil, &block) ⇒ Instance

Returns a new instance of Instance.

Raises:

  • (ArgumentError)


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

#nameObject (readonly)

Returns the value of attribute name.



43
44
45
# File 'lib/queencheck/arbitrary.rb', line 43

def name
  @name
end

Class Method Details

.collectionObject



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

#arbitrary?Boolean

Returns:



45
# File 'lib/queencheck/arbitrary.rb', line 45

def arbitrary?; true; end