Class: FinModeling::AssetsCalculation
Constant Summary
collapse
- BASE_FILENAME =
File.join(FinModeling::BASE_PATH, "summaries/ai_")
- ALL_STATES =
[ :oa, :fa ]
- NEXT_STATES =
{ nil => [ :oa, :fa ],
:oa => [ :oa, :fa ],
:fa => [ :oa, :fa ] }
Instance Attribute Summary
#calculation
Instance Method Summary
collapse
#initialize, #label, #leaf_items, #leaf_items_sum, #periods, #write_constructor
Instance Method Details
#has_cash_item ⇒ Object
38
39
40
41
42
|
# File 'lib/finmodeling/assets_calculation.rb', line 38
def has_cash_item
@has_cash_item = leaf_items.any? do |leaf|
leaf.name.downcase.matches_any_regex?([/cash/])
end
end
|
#mapping ⇒ Object
32
33
34
35
36
|
# File 'lib/finmodeling/assets_calculation.rb', line 32
def mapping
m = Xbrlware::ValueMapping.new
m.policy[:credit] = :flip
m
end
|
#summary(args) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/finmodeling/assets_calculation.rb', line 15
def summary(args)
summary_cache_key = args[:period].to_pretty_s
thesummary = lookup_cached_summary(summary_cache_key)
return thesummary if !thesummary.nil?
thesummary = super(:period => args[:period], :mapping => mapping)
if !lookup_cached_classifications(BASE_FILENAME, thesummary.rows)
lookahead = [4, thesummary.rows.length-1].min
classify_rows(ALL_STATES, NEXT_STATES, thesummary.rows, FinModeling::AssetsItem, lookahead)
save_cached_classifications(BASE_FILENAME, thesummary.rows)
end
save_cached_summary(summary_cache_key, thesummary)
return thesummary
end
|