Sha256: a04ea940f91501a65a3f99ec7d827f0197396a9de4ea0a8ff0517a90b0f9a0dc

Contents?: true

Size: 848 Bytes

Versions: 4

Compression:

Stored size: 848 Bytes

Contents

module Blogit
  module Archive
    class Year
  
      attr_accessor :year, :months
  
      def initialize(year, archiveables)
        @year   = year
        @months = create_months_from_archiveables(archiveables)
      end
  
      def to_s
        year
      end
      
      # The name of the partial to load for a {Year} object
      #
      # Returns a String
      def to_partial_path
        self.class.name.underscore
      end
      
      
      private
      
      
      def create_months_from_archiveables(archiveables)
        months_with_archiveables(archiveables).
          map { |month, archs| Month.new(month, archs) }
      end
      
      def months_with_archiveables(archiveables)
        archiveables.chunk { |a| 
          I18n.localize(a.published_at, format: :plain_month_only) 
        }
      end
  
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
blogit-1.1.2 lib/blogit/archive/year.rb
blogit-1.1.1 lib/blogit/archive/year.rb
blogit-1.1.0 lib/blogit/archive/year.rb
blogit-1.0.0 lib/blogit/archive/year.rb