class BondCalculator::Bond
Bond
is a PORO that represent the structure of benchmark and curve cvs's header
@author Lucas Sant' Anna @since 0.0.1
Attributes
name[R]
term_years[R]
type[R]
yield_percent[R]
Public Class Methods
new(args)
click to toggle source
@param [Hash] args The options to create a Bond
with
@option args [String] :type Type of the Bond
currencty we
implement the calculation for corporate and government only.
@option args [String] :bond Name of the company who is offering the Bond
. @option args [String] :term Number of years to pay. @option args [String] :yield The interest rate.
@return [<void>]
# File lib/bond_calculator/bond.rb, line 23 def initialize(args) @type = format_type(args['type']) @name = format_bond(args['bond']) @term_years = format_term(args['term']) @yield_percent = format_yield(args['yield']) end
Private Instance Methods
format_bond(name)
click to toggle source
# File lib/bond_calculator/bond.rb, line 36 def format_bond(name) name end
format_term(term)
click to toggle source
# File lib/bond_calculator/bond.rb, line 40 def format_term(term) term.split(' ').first.to_f unless term.nil? end
format_type(type)
click to toggle source
# File lib/bond_calculator/bond.rb, line 32 def format_type(type) type end
format_yield(yield_percent)
click to toggle source
# File lib/bond_calculator/bond.rb, line 44 def format_yield(yield_percent) yield_percent&.delete('%').to_f end