Class: Financial::Cost
- Inherits:
-
Object
- Object
- Financial::Cost
- Defined in:
- lib/financial/cost.rb
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
-
#method_name ⇒ Object
Returns the value of attribute method_name.
-
#name ⇒ Object
Returns the value of attribute name.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #+(cost) ⇒ Object
- #==(cost) ⇒ Object
- #format_value ⇒ Object
- #in_date(user_date = nil) ⇒ Object
-
#initialize(cost_name, *arguments) ⇒ Cost
constructor
A new instance of Cost.
- #is_a_received_deposit?(account) ⇒ Boolean
Constructor Details
#initialize(cost_name, *arguments) ⇒ Cost
Returns a new instance of Cost.
5 6 7 8 9 10 11 |
# File 'lib/financial/cost.rb', line 5 def initialize(cost_name, *arguments) arguments.flatten! @name = cost_name.to_s.split('_').join(' ').capitalize @method_name = cost_name @value = arguments.shift @date = Date.today end |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
3 4 5 |
# File 'lib/financial/cost.rb', line 3 def date @date end |
#method_name ⇒ Object
Returns the value of attribute method_name.
3 4 5 |
# File 'lib/financial/cost.rb', line 3 def method_name @method_name end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/financial/cost.rb', line 3 def name @name end |
#value ⇒ Object
Returns the value of attribute value.
3 4 5 |
# File 'lib/financial/cost.rb', line 3 def value @value end |
Instance Method Details
#+(cost) ⇒ Object
22 23 24 |
# File 'lib/financial/cost.rb', line 22 def +(cost) self.value + cost.value end |
#==(cost) ⇒ Object
30 31 32 |
# File 'lib/financial/cost.rb', line 30 def ==(cost) self.value == cost.value and self.method_name == cost.method_name end |
#format_value ⇒ Object
18 19 20 |
# File 'lib/financial/cost.rb', line 18 def format_value "- #{Financial.locale.format_coin(value)}" end |
#in_date(user_date = nil) ⇒ Object
13 14 15 16 |
# File 'lib/financial/cost.rb', line 13 def in_date(user_date=nil) @date = Financial::FinancialDate.new(user_date).date self end |
#is_a_received_deposit?(account) ⇒ Boolean
26 27 28 |
# File 'lib/financial/cost.rb', line 26 def is_a_received_deposit?(account) false end |