Class: Forgery::Monetary

Inherits:
Forgery show all
Defined in:
lib/forgery/forgery/monetary.rb

Constant Summary

Constant Summary

Constants inherited from Forgery

VERSION

Class Method Summary collapse

Methods inherited from Forgery

Extend, dictionaries, formats, load_from!, load_paths, rails?, rails_root

Class Method Details

.formatted_money(options = {}) ⇒ Object



3
4
5
# File 'lib/forgery/forgery/monetary.rb', line 3

def self.formatted_money(options={})
  "$%1.2f" % money(options)
end

.money(options = {}) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/forgery/forgery/monetary.rb', line 7

def self.money(options={})
  options = {:max => 10,
             :min => 0}.merge(options)

  value = Forgery::Extend((options[:min] * 100)..(options[:max] * 100)).random
  "%1.2f" % (value.to_f / 100)
end