Sha256: d77e5afe63ff9cd195511be646cfee1a2325863a4979ab495271c824787ee1c8

Contents?: true

Size: 1.25 KB

Versions: 98

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

require_relative 'section/function_evaluator'

module Checkoff
  module SelectorClasses
    # Section selector classes
    module Section
      # :ends_with_milestone function
      class EndsWithMilestoneFunctionEvaluator < FunctionEvaluator
        FUNCTION_NAME = :ends_with_milestone

        def matches?
          fn?(selector, FUNCTION_NAME)
        end

        # @param section [Asana::Resources::Section]
        #
        # @sg-ignore
        # @return [Boolean]
        def evaluate(section)
          tasks = client.tasks.get_tasks(section: section.gid,
                                         per_page: 100,
                                         options: { fields: ['resource_subtype'] })
          # @sg-ignore
          tasks.last&.resource_subtype == 'milestone'
        end
      end

      # :has_tasks? function
      class HasTasksPFunctionEvaluator < FunctionEvaluator
        FUNCTION_NAME = :has_tasks?

        def matches?
          fn?(selector, FUNCTION_NAME)
        end

        # @param section [Asana::Resources::Section]
        #
        # @sg-ignore
        # @return [Boolean]
        def evaluate(section)
          @sections.tasks_by_section_gid(section.gid).any?
        end
      end
    end
  end
end

Version data entries

98 entries across 98 versions & 1 rubygems

Version Path
checkoff-0.222.0 lib/checkoff/internal/selector_classes/section.rb
checkoff-0.221.0 lib/checkoff/internal/selector_classes/section.rb
checkoff-0.220.0 lib/checkoff/internal/selector_classes/section.rb
checkoff-0.219.0 lib/checkoff/internal/selector_classes/section.rb
checkoff-0.218.0 lib/checkoff/internal/selector_classes/section.rb
checkoff-0.217.0 lib/checkoff/internal/selector_classes/section.rb
checkoff-0.216.0 lib/checkoff/internal/selector_classes/section.rb
checkoff-0.215.0 lib/checkoff/internal/selector_classes/section.rb
checkoff-0.214.0 lib/checkoff/internal/selector_classes/section.rb
checkoff-0.213.0 lib/checkoff/internal/selector_classes/section.rb
checkoff-0.212.0 lib/checkoff/internal/selector_classes/section.rb
checkoff-0.211.0 lib/checkoff/internal/selector_classes/section.rb
checkoff-0.210.0 lib/checkoff/internal/selector_classes/section.rb
checkoff-0.209.0 lib/checkoff/internal/selector_classes/section.rb
checkoff-0.208.0 lib/checkoff/internal/selector_classes/section.rb
checkoff-0.207.0 lib/checkoff/internal/selector_classes/section.rb
checkoff-0.206.0 lib/checkoff/internal/selector_classes/section.rb
checkoff-0.205.0 lib/checkoff/internal/selector_classes/section.rb
checkoff-0.204.0 lib/checkoff/internal/selector_classes/section.rb
checkoff-0.203.0 lib/checkoff/internal/selector_classes/section.rb