class Maybe
Public Instance Methods
==(other)
click to toggle source
# File lib/possibly.rb, line 16 def ==(other) other.class == self.class end
Also aliased as: eql?
inspect()
click to toggle source
# File lib/possibly.rb, line 21 def inspect to_s end
to_ary()
click to toggle source
# File lib/possibly.rb, line 11 def to_ary __enumerable_value end
Also aliased as: to_a
Protected Instance Methods
inst_method()
click to toggle source
# File lib/possibly.rb, line 55 def inst_method "#{print_method(@inst_method)}" end
print_error(msg)
click to toggle source
# File lib/possibly.rb, line 27 def print_error(msg) message = if msg msg + "\n\n" else "\n" end message + print_stack + "\n" end
print_method(invocation)
click to toggle source
# File lib/possibly.rb, line 59 def print_method(invocation) method, args, block = invocation print_method = if method == :[] args.to_s else method.to_s end print_args = if method == :[] nil elsif args.empty? nil else "(#{args.join(', ')})" end [print_method, print_args].compact.join("") end
print_stack()
click to toggle source
# File lib/possibly.rb, line 38 def print_stack longest_method = stack.drop(1).map { |inv| inv.first }.map(&:length).max || 0 stack.map { |(method, value)| method ||= "" "#{method.ljust(longest_method)} => #{value}" }.join("\n") end
self_stack()
click to toggle source
# File lib/possibly.rb, line 50 def self_stack [inst_method, self.inspect] end
stack()
click to toggle source
# File lib/possibly.rb, line 46 def stack @parent_stack + [self_stack] end