Class: Financial::Cost

Inherits:
Object
  • Object
show all
Defined in:
lib/financial/cost.rb

Direct Known Subclasses

Deposit, Parcels, Tax

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#dateObject

Returns the value of attribute date.



3
4
5
# File 'lib/financial/cost.rb', line 3

def date
  @date
end

#method_nameObject

Returns the value of attribute method_name.



3
4
5
# File 'lib/financial/cost.rb', line 3

def method_name
  @method_name
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/financial/cost.rb', line 3

def name
  @name
end

#valueObject

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_valueObject



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

Returns:

  • (Boolean)


26
27
28
# File 'lib/financial/cost.rb', line 26

def is_a_received_deposit?()
  false
end