Sha256: 420e472cd1d75451f6badf3bef797de624dfbb0630a2b0ecc3533e0bcd84d22b

Contents?: true

Size: 708 Bytes

Versions: 4

Compression:

Stored size: 708 Bytes

Contents

$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
$LOAD_PATH.unshift(File.dirname(__FILE__))

module Wowr
	module Classes
		
		# TODO: Fix default to_s option
		class Money
			attr_reader :total
			alias_method :to_i, :total
			alias_method :to_s, :total
			
			def initialize(total)
				@total = total
			end
			
			def gold
				return (@total / 10000)
			end
			
			def silver
				return (@total % 10000) / 100
			end

			def bronze
				return @total % 100
			end
			
			def +(add)
				return Money.new(self.total + add.total)
			end
			
			def -(add)
				return Money.new(self.total - add.total)
			end
		end
		
	end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
pwood-wowr-0.5.1 lib/wowr/general.rb
renchap-wowr-0.5.0 lib/wowr/general.rb
renchap-wowr-0.5.1 lib/wowr/general.rb
renchap-wowr-0.5.3 lib/wowr/general.rb