Displaying 2 results from an estimated 2 matches for "list_of_ints".
2006 Nov 04
0
traits-0.9.2 - better living through metaprogramming
...<========< sample/p.rb >========>
~ > cat sample/p.rb
require ''traits''
#
# the TraitInit module provide a simple method for initializing an object''s
# traits from an options hash
#
class C
include TraitInit
LIST_OF_INTS = lambda{|a| Array === a and a.map{|i| Integer === i}.all?}
LIST_OF_STRINGS = lambda{|a| Array === a and a.map{|s| String ===
s}.all?}
trait :li, :validate => LIST_OF_INTS
trait :ls, :validate => LIST_OF_STRINGS
def initialize opts = {}
trait_init opts...
2006 Nov 04
0
traits-0.10.0
...<========< sample/p.rb >========>
~ > cat sample/p.rb
require ''traits''
#
# the TraitInit module provide a simple method for initializing an object''s
# traits from an options hash
#
class C
include TraitInit
LIST_OF_INTS = lambda{|a| Array === a and a.map{|i| Integer === i}.all?}
LIST_OF_STRINGS = lambda{|a| Array === a and a.map{|s| String === s}.all?}
trait :li, :validate => LIST_OF_INTS
trait :ls, :validate => LIST_OF_STRINGS
def initialize opts = {}
trait_init opts...