Class: Relevance::Tarantula::Attack

Inherits:
Object
  • Object
show all
Defined in:
lib/relevance/tarantula/attack.rb

Constant Summary collapse

HASHABLE_ATTRS =
[:name, :input, :output, :description]

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Attack

Returns a new instance of Attack.



7
8
9
10
11
12
# File 'lib/relevance/tarantula/attack.rb', line 7

def initialize(hash)
  hash.each do |k,v|
    raise ArgumentError, k unless HASHABLE_ATTRS.member?(k)
    self.instance_variable_set("@#{k}", v)
  end
end

Instance Method Details

#==(other) ⇒ Object



13
14
15
# File 'lib/relevance/tarantula/attack.rb', line 13

def ==(other)
  Relevance::Tarantula::Attack === other && HASHABLE_ATTRS.all? { |attr| send(attr) == other.send(attr)}
end

#input(input_field = nil) ⇒ Object



16
17
18
# File 'lib/relevance/tarantula/attack.rb', line 16

def input(input_field=nil)
  @input
end