Sha256: 6a3b74ca2412bc34d5008c16b1930b6846a813fc669b7398bc107f8312baaccc

Contents?: true

Size: 514 Bytes

Versions: 11

Compression:

Stored size: 514 Bytes

Contents

module Billme
	class ServicesSection < Section
		attr_reader :data

		def initialize
			@data = {services: []}
		end

		def method_missing(name, *args, &block)
			return @data[name] = args[0] unless block_given?
			service_details = ServiceDetails.new
			service_details.instance_eval &block
			@data[:services] << service_details.data
		end

		def total
			@data[:services].reduce(0) {|sum, obj| sum += obj[:unit].to_i * obj[:quantity].to_i }
		end

		def subtotal
			total * (1 - @data[:tax].to_f)
		end
	end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
billme-0.44.0 lib/billme/services_section.rb
billme-0.40.0 lib/billme/services_section.rb
billme-0.38.0 lib/billme/services_section.rb
billme-0.37.0 lib/billme/services_section.rb
billme-0.20.0 lib/billme/services_section.rb
billme-0.19.0 lib/billme/services_section.rb
billme-0.13.0 lib/billme/services_section.rb
billme-0.6.0 lib/billme/services_section.rb
billme-0.5.0 lib/billme/services_section.rb
billme-0.2.0 lib/billme/services_section.rb
billme-0.1.0 lib/billme/services_section.rb