Class: ContractLtd::Dividend

Inherits:
Object
  • Object
show all
Defined in:
lib/contract_ltd/dividend.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Dividend

Returns a new instance of Dividend.



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/contract_ltd/dividend.rb', line 5

def initialize args
  @name = 'dividend'
  @type = ARGV[0]
  @article = @type == 'final' ? 'a' : 'an'
  @date_paid = Date.parse(ARGV[1])
  @tax_year_end = Date.new(ARGV[2].to_i, 4, 5).to_s(:long)
  @shares = 100
  @net = ARGV[3].to_f
  @tax_credit = @net * 0.111111
  @gross = @net + @tax_credit
  @amount = @net / @shares
  @company_year_end = Date.new(ARGV[4].to_i, 2, 28).to_s(:long)
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



3
4
5
# File 'lib/contract_ltd/dividend.rb', line 3

def amount
  @amount
end

#articleObject (readonly)

Returns the value of attribute article.



3
4
5
# File 'lib/contract_ltd/dividend.rb', line 3

def article
  @article
end

#company_year_endObject (readonly)

Returns the value of attribute company_year_end.



3
4
5
# File 'lib/contract_ltd/dividend.rb', line 3

def company_year_end
  @company_year_end
end

#grossObject (readonly)

Returns the value of attribute gross.



3
4
5
# File 'lib/contract_ltd/dividend.rb', line 3

def gross
  @gross
end

#netObject (readonly)

Returns the value of attribute net.



3
4
5
# File 'lib/contract_ltd/dividend.rb', line 3

def net
  @net
end

#sharesObject (readonly)

Returns the value of attribute shares.



3
4
5
# File 'lib/contract_ltd/dividend.rb', line 3

def shares
  @shares
end

#tax_creditObject (readonly)

Returns the value of attribute tax_credit.



3
4
5
# File 'lib/contract_ltd/dividend.rb', line 3

def tax_credit
  @tax_credit
end

#tax_year_endObject (readonly)

Returns the value of attribute tax_year_end.



3
4
5
# File 'lib/contract_ltd/dividend.rb', line 3

def tax_year_end
  @tax_year_end
end

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/contract_ltd/dividend.rb', line 3

def type
  @type
end

Instance Method Details

#date_paid(format = :long) ⇒ Object



19
20
21
# File 'lib/contract_ltd/dividend.rb', line 19

def date_paid(format = :long)
  @date_paid.to_s(format)
end

#filenameObject



27
28
29
# File 'lib/contract_ltd/dividend.rb', line 27

def filename
  "#{@name}_#{date_paid(:file)}.pdf"
end

#name(ext) ⇒ Object



23
24
25
# File 'lib/contract_ltd/dividend.rb', line 23

def name(ext)
  "#{@name}.#{ext}"
end