Sha256: a6beae9cc2244de28ca538afc71698f6cadaa86e254355d15e74374b6e65333c

Contents?: true

Size: 1.45 KB

Versions: 6

Compression:

Stored size: 1.45 KB

Contents

module Troo
  module External
    class CardAdaptor
      class << self
        def adapt(resource)
          new(resource).adapted
        end
      end

      def initialize(resource)
        @resource = resource
      end

      def adapted
        {
          external_board_id:   external_board_id,
          external_list_id:    external_list_id,
          external_card_id:    external_card_id,
          external_member_ids: external_member_ids,
          short_id:            short_id,
          name:                name,
          desc:                desc,
          url:                 url,
          position:            position,
          last_activity_date:  last_activity_date,
          closed:              closed,
        }
      end

      private
      attr_reader :resource

      def external_board_id
        resource.board_id
      end

      def external_list_id
        resource.list_id
      end

      def external_card_id
        resource.id
      end

      def external_member_ids
        resource.member_ids.to_s.gsub(" ", "")
      end

      def short_id
        resource.short_id.to_s
      end

      def name
        resource.name
      end

      def desc
        resource.desc
      end

      def url
        resource.url
      end

      def position
        resource.pos.to_s
      end

      def last_activity_date
        resource.last_activity_date.to_s
      end

      def closed
        resource.closed.to_s
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
troo-0.0.7 lib/troo/external/card_adaptor.rb
troo-0.0.6 lib/troo/external/card_adaptor.rb
troo-0.0.5 lib/troo/external/card_adaptor.rb
troo-0.0.4 lib/troo/external/card_adaptor.rb
troo-0.0.3 lib/troo/external/card_adaptor.rb
troo-0.0.2 lib/troo/external/card_adaptor.rb