E
Eugen Ciur
Hi
I want to buid up module of Financial variables.
It can be used like this
Financial.year.start #returns start of ... guess what
Financial.year.finish
Financial.quarter.start
Financial.quarter.end
...
You got the idea. It must be easily extensible.
Here is what I came up with:
#!/usr/lib/ruby
module FinancialYear
def year
EndPoint.new
end
class EndPoint
def start
@start = "01/01/"+Time.now.strftime("%Y")
end
def finish
@finish = "31/12/"+Time.now.strftime("%Y")
end
end
end
module Period
def self.included(base)
base.extend(FinancialYear)
end
end
module Financial
include Period
end
I used mostly idioms from Metaprogramming Ruby - Class Extension Mixin
Any suggestion for improvement ?
I am novice in ruby so any suggestion is welcome !
I want to buid up module of Financial variables.
It can be used like this
Financial.year.start #returns start of ... guess what
Financial.year.finish
Financial.quarter.start
Financial.quarter.end
...
You got the idea. It must be easily extensible.
Here is what I came up with:
#!/usr/lib/ruby
module FinancialYear
def year
EndPoint.new
end
class EndPoint
def start
@start = "01/01/"+Time.now.strftime("%Y")
end
def finish
@finish = "31/12/"+Time.now.strftime("%Y")
end
end
end
module Period
def self.included(base)
base.extend(FinancialYear)
end
end
module Financial
include Period
end
I used mostly idioms from Metaprogramming Ruby - Class Extension Mixin
Any suggestion for improvement ?
I am novice in ruby so any suggestion is welcome !