Sha256: 0ef3e35c75c6d4b8d3fad461413127262f4356e8d9dcedbf5c40709b9af43e58
Contents?: true
Size: 1.44 KB
Versions: 2
Compression:
Stored size: 1.44 KB
Contents
module Uncool # class Unit attr :target attr :method attr :function def initialize(target, method, props={}) @target = target @method = method.to_sym @function = props[:function] ? true : false @covered = props[:covered] if @function @private = !@target.public_methods.find{ |m| m.to_sym == @method } else @private = !@target.public_instance_methods.find{ |m| m.to_sym == @method } end end # Method access is private or protected? def private? @private end # Marked as covered? def covered? @covered end # def function? @function end # def hash @target.hash ^ @method.hash ^ @function.hash end # def to_s if @function "#{@target}.#{@method}" else "#{@target}##{@method}" end end alias to_str to_s def eql?(other) return false unless Unit === other return false unless target == other.target return false unless method == other.method return false unless function == other.function return true end def inspect "#{target}#{function ? '.' : '#'}#{method}" end def <=>(other) c = (target.name <=> other.target.name) return c unless c == 0 return -1 if function && !other.function return 1 if !function && other.function method.to_s <=> other.method.to_s end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
uncool-1.0.1 | lib/uncool/unit.rb |
uncool-1.0.0 | lib/uncool/unit.rb |