Class: Piggly::Tags::ConditionalBranchTag

Inherits:
AbstractTag show all
Defined in:
lib/piggly/tags.rb

Overview

Tracks if, catch, case branch, continue when, and exit when statements where the coverage consists of the condition evaluating true and false

Constant Summary

Constants inherited from AbstractTag

AbstractTag::PATTERN

Instance Attribute Summary collapse

Attributes inherited from AbstractTag

#id

Instance Method Summary collapse

Methods inherited from AbstractTag

#tap

Constructor Details

#initialize(*args) ⇒ ConditionalBranchTag

Returns a new instance of ConditionalBranchTag.



96
97
98
99
# File 'lib/piggly/tags.rb', line 96

def initialize(*args)
  clear
  super
end

Instance Attribute Details

#falseObject (readonly)

Returns the value of attribute false.



94
95
96
# File 'lib/piggly/tags.rb', line 94

def false
  @false
end

#trueObject (readonly)

Returns the value of attribute true.



94
95
96
# File 'lib/piggly/tags.rb', line 94

def true
  @true
end

Instance Method Details

#==(other) ⇒ Object



140
141
142
# File 'lib/piggly/tags.rb', line 140

def ==(other)
  @id == other.id and @true == other.true and @false == other.false
end

#clearObject



136
137
138
# File 'lib/piggly/tags.rb', line 136

def clear
  @true, @false  = false
end

#complete?Boolean

Returns:



120
121
122
# File 'lib/piggly/tags.rb', line 120

def complete?
  @true and @false
end

#descriptionObject



124
125
126
127
128
129
130
131
132
133
134
# File 'lib/piggly/tags.rb', line 124

def description
  if @true and @false
    "full coverage"
  elsif @true
    "never evaluates false"
  elsif @false
    "never evaluates true"
  else
    "never evaluated"
  end
end

#ping(value) ⇒ Object



105
106
107
108
109
110
# File 'lib/piggly/tags.rb', line 105

def ping(value)
  case value
  when "t"; @true  = true
  when "f"; @false = true
  end
end

#styleObject



112
113
114
# File 'lib/piggly/tags.rb', line 112

def style
  "b#{@true ? 1 : 0}#{@false ? 1 : 0 }"
end

#to_fObject



116
117
118
# File 'lib/piggly/tags.rb', line 116

def to_f
  (@true and @false) ? 100.0 : (@true or @false) ? 50.0 : 0.0
end

#typeObject



101
102
103
# File 'lib/piggly/tags.rb', line 101

def type
  :branch
end