Class: Mumukit::Inspection

Inherits:
Object
  • Object
show all
Defined in:
lib/mumukit/inspection.rb,
lib/mumukit/inspection/version.rb

Defined Under Namespace

Modules: I18n Classes: Expectation, Target

Constant Summary collapse

VERSION =
'3.4.0'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, target, negated = false) ⇒ Inspection

Returns a new instance of Inspection.


12
13
14
15
16
# File 'lib/mumukit/inspection.rb', line 12

def initialize(type, target, negated=false)
  @type = type
  @target = target
  @negated = negated
end

Instance Attribute Details

#negatedObject Also known as: negated?

Returns the value of attribute negated.


9
10
11
# File 'lib/mumukit/inspection.rb', line 9

def negated
  @negated
end

#targetObject

Returns the value of attribute target.


9
10
11
# File 'lib/mumukit/inspection.rb', line 9

def target
  @target
end

#typeObject

Returns the value of attribute type.


9
10
11
# File 'lib/mumukit/inspection.rb', line 9

def type
  @type
end

Class Method Details

.parse(insepection_s) ⇒ Object


38
39
40
41
# File 'lib/mumukit/inspection.rb', line 38

def self.parse(insepection_s)
  raise "Invalid inspection #{insepection_s}" unless insepection_s =~ /^(Not\:)?([^\:]+)\:?(.+)?$/
  Inspection.new($2, Mumukit::Inspection::Target.parse($3), $1.present?)
end

.parse_binding_name(binding_s) ⇒ Object


30
31
32
33
34
35
36
# File 'lib/mumukit/inspection.rb', line 30

def self.parse_binding_name(binding_s)
  if binding_s.start_with? 'Intransitive:'
    binding_s[13..-1]
  else
    binding_s
  end
end

Instance Method Details

#negated_to_sObject


22
23
24
# File 'lib/mumukit/inspection.rb', line 22

def negated_to_s
  negated ? 'Not:' : nil
end

#target_to_sObject


26
27
28
# File 'lib/mumukit/inspection.rb', line 26

def target_to_s
  target ? ":#{target.to_s}" : nil
end

#to_sObject


18
19
20
# File 'lib/mumukit/inspection.rb', line 18

def to_s
  "#{negated_to_s}#{type}#{target_to_s}"
end