class Lemon::Snapshot::Unit
Snapshot
Unit
encapsulates a method and it's various characteristics.
Attributes
covered[RW]
Can be used to flag a unit as covered.
method[R]
Method name.
singleton[R]
Is the method a “class method”, rather than an instance method.
target[R]
Clsss or module.
Public Class Methods
new(target, method, props={})
click to toggle source
# File lib/lemon/coverage/snapshot.rb, line 110 def initialize(target, method, props={}) @target = target @method = method.to_sym @singleton = props[:singleton] ? true : false @covered = props[:covered] if @singleton @private = @target.private_methods.find{ |m| m.to_sym == @method } @protected = @target.protected_methods.find{ |m| m.to_sym == @method } else @private = @target.private_instance_methods.find{ |m| m.to_sym == @method } @protected = @target.protected_instance_methods.find{ |m| m.to_sym == @method } end end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/lemon/coverage/snapshot.rb, line 192 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
access()
click to toggle source
# File lib/lemon/coverage/snapshot.rb, line 154 def access return :private if private? return :protected if protected? :public end
covered?()
click to toggle source
Marked as covered?
# File lib/lemon/coverage/snapshot.rb, line 161 def covered? @covered end
eql?(other)
click to toggle source
# File lib/lemon/coverage/snapshot.rb, line 180 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/snapshot.rb, line 166 def hash @target.hash ^ @method.hash ^ @singleton.hash end
inspect()
click to toggle source
# File lib/lemon/coverage/snapshot.rb, line 188 def inspect "#{target}#{singleton ? '.' : '#'}#{method}" end
namespace()
click to toggle source
Alternate name for target.
# File lib/lemon/coverage/snapshot.rb, line 129 def namespace @target end
private?()
click to toggle source
Method access is public?
# File lib/lemon/coverage/snapshot.rb, line 144 def private? @private end
protected?()
click to toggle source
# File lib/lemon/coverage/snapshot.rb, line 149 def protected? @protected end
public?()
click to toggle source
Method access is public?
# File lib/lemon/coverage/snapshot.rb, line 139 def public? !(@private or @protected) end
singleton?()
click to toggle source
# File lib/lemon/coverage/snapshot.rb, line 134 def singleton? @singleton end
to_s()
click to toggle source
# File lib/lemon/coverage/snapshot.rb, line 171 def to_s if @singleton "#{@target}.#{@method}" else "#{@target}##{@method}" end end
Also aliased as: to_str