Class: Hackle::TargetMatchType

Inherits:
Object
  • Object
show all
Defined in:
lib/hackle/internal/model/target.rb

Constant Summary collapse

MATCH =
new('MATCH')
NOT_MATCH =
new('NOT MATCH')

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ TargetMatchType

Returns a new instance of TargetMatchType.

Parameters:

  • name (String)


116
117
118
# File 'lib/hackle/internal/model/target.rb', line 116

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



113
114
115
# File 'lib/hackle/internal/model/target.rb', line 113

def name
  @name
end

Class Method Details

.from_or_nil(name) ⇒ TargetMatchType?

Parameters:

  • name (String)

Returns:



134
135
136
# File 'lib/hackle/internal/model/target.rb', line 134

def self.from_or_nil(name)
  @types[name.upcase]
end

.matches(type, matches) ⇒ boolean

Parameters:

Returns:

  • (boolean)


146
147
148
149
150
151
152
153
154
155
# File 'lib/hackle/internal/model/target.rb', line 146

def self.matches(type, matches)
  case type
  when MATCH
    matches
  when NOT_MATCH
    !matches
  else
    raise ArgumentError, "Unsupported type: #{type}"
  end
end

.valuesArray<TargetMatchType>

Returns:



139
140
141
# File 'lib/hackle/internal/model/target.rb', line 139

def self.values
  @types.values
end

Instance Method Details

#to_sObject



120
121
122
# File 'lib/hackle/internal/model/target.rb', line 120

def to_s
  name
end