module MITS::V3_0::Mapper::DepositMapper

Public Instance Methods

deposit(tag, entity = Deposit) click to toggle source
# File lib/mits/v3.0/mapper/deposit_mapper.rb, line 10
def deposit(tag, entity = Deposit)
  entity.new(amount:             deposit_amount(tag[:Amount][:ValueRange]),
             description:        tag[:Description],
             percent_refundable: try(tag[:PercentRefundable], :to_f),
             portion_refundable: try(tag[:PortionRefundable], :to_f),
             type:               tag[:DepositType])
end
deposits(tags, entity = Deposit) click to toggle source
# File lib/mits/v3.0/mapper/deposit_mapper.rb, line 5
def deposits(tags, entity = Deposit)
  tags = [tags] unless tags.is_a? Array
  tags.map { |tag| deposit(tag, entity) }
end

Private Instance Methods

deposit_amount(tag) click to toggle source
# File lib/mits/v3.0/mapper/deposit_mapper.rb, line 19
def deposit_amount(tag)
  if tag[:Exact]
    amount = tag[:Exact].to_f
  else
    min = tag[:Min].to_f
    max = tag[:Max].to_f
    amount = Range.new(min, max)
  end
  amount
end