Class: RubyOnAcid::ConstantFactory

Inherits:
Factory
  • Object
show all
Defined in:
lib/rubyonacid/factories/constant.rb

Overview

A factory that returns a preset value for all keys.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Factory

#boolean, #choose, #get, #within

Constructor Details

#initialize(value = 0.5) ⇒ ConstantFactory

Returns a new instance of ConstantFactory.



15
16
17
18
# File 'lib/rubyonacid/factories/constant.rb', line 15

def initialize(value = 0.5)
  super
  @value = value
end

Instance Attribute Details

#valueObject

A value between 0 and 1 that get_unit will return.



9
10
11
# File 'lib/rubyonacid/factories/constant.rb', line 9

def value
  @value
end

Instance Method Details

#get_unit(key) ⇒ Object

Returns assigned value.



21
22
23
# File 'lib/rubyonacid/factories/constant.rb', line 21

def get_unit(key)
  @value
end