Sha256: 0efb149ac2ca38b0918827d020c21cf3e9c779fffdad4dca85d8e198b3f4dfaa

Contents?: true

Size: 828 Bytes

Versions: 1

Compression:

Stored size: 828 Bytes

Contents

module BottleRocket
  module TagBuilders

    class UnitContainerBuilder
      include ::BottleRocket::ContentTags

      attr_reader :unit, :time_unit, :unit_separator

      def initialize(unit, unit_value, separator_options)
        @unit           = unit
        @time_unit      = TimeUnitBuilder.new unit, unit_value
        @unit_separator = UnitSeparatorBuilder.new unit, separator_options.merge(singularize: singularize?)
      end

      def singularize?
        time_unit.one?
      end

      def to_html
        ContentTag.new(:span, class: unit.to_s).to_s do
          if unit_separator.after?
            [time_unit.to_html, unit_separator.to_html].join
          else
            [unit_separator.to_html, time_unit.to_html].join
          end
        end
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bottle_rocket-0.0.1 lib/bottle_rocket/tag_builders/unit_container_builder.rb