Class: Agentilda::Linear::Attribution::Placed

Inherits:
Data
  • Object
show all
Defined in:
lib/agentilda/linear/attribution.rb

Overview

One pull request, placed.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pullAgentilda::PullRequest (readonly)



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/agentilda/linear/attribution.rb', line 34

Placed = Data.define(:pull, :subject, :score, :rivals, :widened) do
  # @return [Boolean]
  def placed? = !subject.nil?

  # @return [String]
  def percent = "#{(score * 100).round}%"

  # @return [String] where the matching words came from
  def source = widened ? "title and description" : "title"

  # @return [String]
  def why
    return "matched no folder at all" if subject.nil? && score.zero?
    return "#{percent} of a folder name is not enough" if subject.nil? && rivals.empty?
    # `rivals` already holds every tied folder — there is no winner to
    # add back in, and `+ 1` here once reported a two-way tie as three.
    return "#{rivals.size} folders matched equally well (#{percent})" if subject.nil?

    "#{source}: covers #{percent} of the folder name"
  end
end

#rivalsArray<String> (readonly)

Returns folders that matched equally well.

Returns:

  • (Array<String>)

    folders that matched equally well



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/agentilda/linear/attribution.rb', line 34

Placed = Data.define(:pull, :subject, :score, :rivals, :widened) do
  # @return [Boolean]
  def placed? = !subject.nil?

  # @return [String]
  def percent = "#{(score * 100).round}%"

  # @return [String] where the matching words came from
  def source = widened ? "title and description" : "title"

  # @return [String]
  def why
    return "matched no folder at all" if subject.nil? && score.zero?
    return "#{percent} of a folder name is not enough" if subject.nil? && rivals.empty?
    # `rivals` already holds every tied folder — there is no winner to
    # add back in, and `+ 1` here once reported a two-way tie as three.
    return "#{rivals.size} folders matched equally well (#{percent})" if subject.nil?

    "#{source}: covers #{percent} of the folder name"
  end
end

#scoreInteger (readonly)

Returns words the title and the folder name shared.

Returns:

  • (Integer)

    words the title and the folder name shared



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/agentilda/linear/attribution.rb', line 34

Placed = Data.define(:pull, :subject, :score, :rivals, :widened) do
  # @return [Boolean]
  def placed? = !subject.nil?

  # @return [String]
  def percent = "#{(score * 100).round}%"

  # @return [String] where the matching words came from
  def source = widened ? "title and description" : "title"

  # @return [String]
  def why
    return "matched no folder at all" if subject.nil? && score.zero?
    return "#{percent} of a folder name is not enough" if subject.nil? && rivals.empty?
    # `rivals` already holds every tied folder — there is no winner to
    # add back in, and `+ 1` here once reported a two-way tie as three.
    return "#{rivals.size} folders matched equally well (#{percent})" if subject.nil?

    "#{source}: covers #{percent} of the folder name"
  end
end

#subjectAgentilda::Subject? (readonly)

Returns nil when nothing matched.

Returns:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/agentilda/linear/attribution.rb', line 34

Placed = Data.define(:pull, :subject, :score, :rivals, :widened) do
  # @return [Boolean]
  def placed? = !subject.nil?

  # @return [String]
  def percent = "#{(score * 100).round}%"

  # @return [String] where the matching words came from
  def source = widened ? "title and description" : "title"

  # @return [String]
  def why
    return "matched no folder at all" if subject.nil? && score.zero?
    return "#{percent} of a folder name is not enough" if subject.nil? && rivals.empty?
    # `rivals` already holds every tied folder — there is no winner to
    # add back in, and `+ 1` here once reported a two-way tie as three.
    return "#{rivals.size} folders matched equally well (#{percent})" if subject.nil?

    "#{source}: covers #{percent} of the folder name"
  end
end

#widenedObject (readonly)

Returns the value of attribute widened

Returns:

  • (Object)

    the current value of widened



34
35
36
# File 'lib/agentilda/linear/attribution.rb', line 34

def widened
  @widened
end

Instance Method Details

#percentString

Returns:

  • (String)


39
# File 'lib/agentilda/linear/attribution.rb', line 39

def percent = "#{(score * 100).round}%"

#placed?Boolean

Returns:

  • (Boolean)


36
# File 'lib/agentilda/linear/attribution.rb', line 36

def placed? = !subject.nil?

#sourceString

Returns where the matching words came from.

Returns:

  • (String)

    where the matching words came from



42
# File 'lib/agentilda/linear/attribution.rb', line 42

def source = widened ? "title and description" : "title"

#whyString

Returns:

  • (String)


45
46
47
48
49
50
51
52
53
# File 'lib/agentilda/linear/attribution.rb', line 45

def why
  return "matched no folder at all" if subject.nil? && score.zero?
  return "#{percent} of a folder name is not enough" if subject.nil? && rivals.empty?
  # `rivals` already holds every tied folder — there is no winner to
  # add back in, and `+ 1` here once reported a two-way tie as three.
  return "#{rivals.size} folders matched equally well (#{percent})" if subject.nil?

  "#{source}: covers #{percent} of the folder name"
end