lib/fiscal_year.rb in fiscal_year-0.1.0 vs lib/fiscal_year.rb in fiscal_year-0.2.0
- old
+ new
@@ -1,40 +1,41 @@
# frozen_string_literal: true
require_relative "fiscal_year/version"
-require 'fiscal_year/half'
-require 'fiscal_year/quarter'
-require 'fiscal_year/year_to_date'
-require 'fiscal_year/config'
+require "fiscal_year/half"
+require "fiscal_year/quarter"
+require "fiscal_year/year_to_date"
+require "fiscal_year/config"
-require 'active_support'
-require 'active_support/core_ext'
+require "active_support"
+require "active_support/core_ext"
module FiscalYear
- @@config ||= FiscalYear::Config.new
+ @config ||= FiscalYear::Config.new
+
class << self
- def config
- @@config
+ attr_reader :config
+
+ def configure
+ yield(@config) if block_given?
end
-
- def configure(&block)
- yield(@@config) if block_given?
- end
def cross_year_month?(month)
cross_year_months.include?(month)
end
-
+
def cross_year?
months.rindex(1) != 0
end
def months
- (1..12).to_a.tap { |arr| arr.concat(arr.shift(@@config.start_month - 1)) }
+ (1..12).to_a.tap { |arr| arr.concat(arr.shift(@config.start_month - 1)) }
end
def cross_year_months
+ return [] if @config.start_month == 1
+
months.slice(months.rindex(1), months.length)
end
def halfs
months.in_groups(2)