lib/patternmatching.rb in patternmatching-0.2.2 vs lib/patternmatching.rb in patternmatching-0.2.3
- old
+ new
@@ -1,11 +1,11 @@
require 'patternmatching/version'
require 'patternmatching/pattern'
module PatternMatching
- # The module is only for showing example docs.
+ # The module is only for showing usage...
#== Using module
# # If installed from rubygems
# require "rubygems"
# gem "patternmatching"
#
@@ -31,29 +31,10 @@
# end
# end
#
# p Calc.new.calcm(code)
#
- #== Another partial style method example
- # class CalcX
- # extend PatternMatching
- #
- # func(:calcx) do
- # seems as {plus(:a, :b)} do
- # calcx(a) + calcx(b)
- # end
- # seems as {mul(:a, :b)} do
- # calcx(a) * calcx(b)
- # end
- # end
- # func(:calcx).seems as {:value} do
- # value
- # end
- # end
- #
- # p CalcX.new.calcx(code)
- #
#== Pattern matching example
# include PatternMatching
#
# def calc(code)
# make(code) {
@@ -63,49 +44,10 @@
# }
# end
#
# p calc(code)
#
- #== Enumerable matching example
- # is = build { exact([1,2,3,4,5]) }
- # make is do
- # seems as {exact([:a,:b, _!(:c)])} do
- # puts a.to_s + ", " + b.to_s + " and " + c.to_s
- # end
- # seems something do
- # puts "not matched"
- # end
- # end
- #
- #== Hash to Hash matching example
- # dict = build { {:name => "Taro", :age => 5} }
- # make dict do
- # seems as {{:name => :name}} do
- # puts "He is " + name
- # end
- # seems something do
- # puts "no name"
- # end
- # end
- #
- #== Hash to non-Hash object matching example
- # class Person
- # def initialize(name, age)
- # @name = name
- # @age = age
- # end
- # attr :name
- # attr :age
- # end
- #
- # make Person.new("Jiro", 3) do
- # seems as {{:name => :name}} do
- # puts "He is " + name
- # end
- # seems something do
- # puts "no name"
- # end
- # end
- #
- module EXAMPLES
+ #== For more
+ #see README.txt
+ module USAGE
end
end