Sha256: 4ba33f209453fd55716e7c8634cb95cb2b80cfb818a8f4d757718174f3836b76

Contents?: true

Size: 788 Bytes

Versions: 2

Compression:

Stored size: 788 Bytes

Contents

module Rocx
  module Properties
    class Tabs < BaseProperty
      include Enumerable

      def initialize
        @tabs = []
      end

      def <<(tab)
        raise ArgumentError, invalid_tab_message unless valid_tab?(tab)
        tabs << tab
      end

      def each(*args, &block)
        tabs.each *args, &block
      end

      def render?
        !tabs.length.zero?
      end

      def to_xml(xml)
        return unless render?

        xml["w"].public_send(tag) {
          each { |tab| tab.to_xml(xml) }
        }
      end

    protected

      attr_reader :tabs

    private

      def invalid_tab_message
        "Tabs must be instances of Rocx::Properties::Tab"
      end

      def valid_tab?(tab)
        tab.is_a?(Rocx::Properties::Tab)
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rocx-0.6.0 lib/rocx/properties/tabs.rb
rocx-0.5.8 lib/rocx/properties/tabs.rb