class Lemon::CoverUnit

Unit of coverage, ecapsulates a method, it's characteristics and a flag as to whether it has been covered or not.

Attributes

method[R]
singleton[R]
target[R]

Public Class Methods

new(target, method, props={}) click to toggle source
# File lib/lemon/coverage/cover_unit.rb, line 14
def initialize(target, method, props={})
  @target    = target
  @method    = method.to_sym
  @covered   = props[:covered]
  @singleton = props[:singleton] ? true : false

  if @singleton
    @private = !@target.public_methods.find{ |m| m.to_sym == @method }
  else
    @private = !@target.public_instance_methods.find{ |m| m.to_sym == @method }
  end
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/lemon/coverage/cover_unit.rb, line 90
def <=>(other)
  c = (target.name <=> other.target.name)
  return c unless c == 0
  return -1 if singleton  && !other.singleton
  return  1 if !singleton && other.singleton
  method.to_s <=> other.method.to_s
end
class_method?()
Alias for: singleton?
covered?() click to toggle source

Marked as covered?

# File lib/lemon/coverage/cover_unit.rb, line 37
def covered?
  @covered
end
eql?(other) click to toggle source
# File lib/lemon/coverage/cover_unit.rb, line 72
def eql?(other)
  return false unless Unit === other
  return false unless target == other.target
  return false unless method == other.method
  return false unless singleton == other.singleton
  return true
end
hash() click to toggle source
# File lib/lemon/coverage/cover_unit.rb, line 53
def hash
  @target.hash ^ @method.hash ^ singleton.hash
end
inspect() click to toggle source
# File lib/lemon/coverage/cover_unit.rb, line 83
def inspect
  "#{target}#{singleton? ? '.' : '#'}#{method}"
end
private?() click to toggle source

Method access is private or protected?

# File lib/lemon/coverage/cover_unit.rb, line 30
def private?
  @private
end
singleton?() click to toggle source
# File lib/lemon/coverage/cover_unit.rb, line 44
def singleton?
  @singleton
end
Also aliased as: class_method?
to_s() click to toggle source
# File lib/lemon/coverage/cover_unit.rb, line 60
def to_s
  if singleton?
    "#{@target}.#{@method}"
  else
    "#{@target}##{@method}"
  end
end
Also aliased as: to_str
to_str()
Alias for: to_s