Sha256: 119107cb82166f7cf5c149f2498ebda0615e0f1700b5715bb6d68654bb0972ef

Contents?: true

Size: 1.62 KB

Versions: 3

Compression:

Stored size: 1.62 KB

Contents

# encoding: UTF-8

module Bunto
  module Drops
    class UrlDrop < Drop
      extend Forwardable

      mutable false

      def_delegator :@obj, :cleaned_relative_path, :path
      def_delegator :@obj, :output_ext, :output_ext

      def collection
        @obj.collection.label
      end

      def name
        Utils.slugify(@obj.basename_without_ext)
      end

      def title
        Utils.slugify(@obj.data['slug'], :mode => "pretty", :cased => true) ||
          Utils.slugify(@obj.basename_without_ext, :mode => "pretty", :cased => true)
      end

      def slug
        Utils.slugify(@obj.data['slug']) || Utils.slugify(@obj.basename_without_ext)
      end

      def categories
        category_set = Set.new
        Array(@obj.data['categories']).each do |category|
          category_set << category.to_s.downcase
        end
        category_set.to_a.join('/')
      end

      def year
        @obj.date.strftime("%Y")
      end

      def month
        @obj.date.strftime("%m")
      end

      def day
        @obj.date.strftime("%d")
      end

      def hour
        @obj.date.strftime("%H")
      end

      def minute
        @obj.date.strftime("%M")
      end

      def second
        @obj.date.strftime("%S")
      end

      def i_day
        @obj.date.strftime("%-d")
      end

      def i_month
        @obj.date.strftime("%-m")
      end

      def short_month
        @obj.date.strftime("%b")
      end

      def short_year
        @obj.date.strftime("%y")
      end

      def y_day
        @obj.date.strftime("%j")
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bunto-3.0.0 lib/bunto/drops/url_drop.rb
bunto-2.0.0.pre lib/bunto/drops/url_drop.rb
bunto-1.0.0 lib/bunto/drops/url_drop.rb