Sha256: f9af1fac3c6c690e7bfa2169bfbed32392975290e3458ea5361a6abb2a19901a
Contents?: true
Size: 659 Bytes
Versions: 4
Compression:
Stored size: 659 Bytes
Contents
require 'myrrha' PosInt = Myrrha.domain(Integer){|i| i>0} ### PosInt.class PosInt.superclass PosInt.ancestors PosInt === 10 PosInt === -1 PosInt.new(10) begin PosInt.new(-10) raise "Unexpected case: PosInt.new(-10) succeeds" rescue ArgumentError => ex puts ex.message end ### 10.is_a?(PosInt) 10.kind_of?(PosInt) ### rules = Myrrha.coercions do |r| r.coercion String, Integer, lambda{|s,t| Integer(s)} end rules.coerce("12", Integer) rules.coerce("12", PosInt) rules.coerce("-12", Integer) begin rules.coerce("-12", PosInt) raise "Unexpected case: rules.coerce('-12', PosInt) succeeds" rescue Myrrha::Error => ex puts ex.message end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
myrrha-1.2.2 | examples/sbyc_domain.rb |
myrrha-1.2.1 | examples/sbyc_domain.rb |
myrrha-1.2.0 | examples/sbyc_domain.rb |
myrrha-1.1.0 | examples/sbyc_domain.rb |