Module: Hours
- Defined in:
- lib/hours/time.rb,
lib/hours/version.rb
Defined Under Namespace
Classes: Time
Constant Summary collapse
- VERSION =
'0.0.1'
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.hr(*args) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/hours/time.rb', line 25 def self.hr(*args) if args.size == 2 Hours::Time.new(args[1]) - Hours::Time.new(args[0]) elsif args.size == 1 return self.hr(args[0].begin, args[0].end) if args[0].kind_of?(Range) return (args[0].inject(0) {|r,e| r + self.hr(e.first, e.last)}) if args[0].kind_of?(Hash) else raise ArgumentError, 'incorrect argument type' end end |