Class: Xbrlware::Context::Period
- Inherits:
-
Object
- Object
- Xbrlware::Context::Period
- Defined in:
- lib/xbrlware-extras/context.rb
Instance Method Summary collapse
Instance Method Details
#days ⇒ Object
30 31 32 |
# File 'lib/xbrlware-extras/context.rb', line 30 def days Xbrlware::DateUtil.days_between(@value["end_date"], @value["start_date"]) end |
#plus_n_months(n) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/xbrlware-extras/context.rb', line 34 def plus_n_months(n) case when is_instant? new_value = @value.dup n.times do new_value = new_value.next_month end return Period.new(new_value) when is_duration? new_value = {"start_date"=>@value["start_date"].dup, "end_date"=>@value["end_date"].dup} n.times do new_value["start_date"] = new_value["start_date"].next_month new_value[ "end_date"] = new_value[ "end_date"].next_month end return Period.new(new_value) end raise RuntimeError.new("not supported") end |
#to_pretty_s ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/xbrlware-extras/context.rb', line 53 def to_pretty_s case when is_instant? return "#{@value}" when is_duration? return "#{@value["start_date"]} to #{@value["end_date"]}" else return to_s end end |