Sha256: b12f058110c44bcadb9777297f44d103eff38a7b492d97e8d64d6b2efa3ecb04
Contents?: true
Size: 1.58 KB
Versions: 3
Compression:
Stored size: 1.58 KB
Contents
class Checked class Demand class Arrays < Sinatra::Base include Checked::Arch map '/array!' get def check! array! return! end get def no_nils! demand \ return!.include?(nil), \ "...can't contain nils." end get def no_empty_strings! return!.each { |memo,s| final = if s.respond_to?(:readlines) s.rewind s.readlines else s end demand \ final.is_a?(::String), \ "...can't contain unknown class: #{final.inspect}" demand \ final.is_a?(::String) && final.strip.empty?, \ "...can't contain empty strings." } return! end get def symbols! Checked::App.new.get!("/array!/not_empty!", 'name'=>target_name, 'value'=>return!, 'args'=>[]) demand \ return!.all? { |v| v.is_a?(Symbol) }, \ "...contains a non-symbol." end get def include! demand return!.include?(matcher), \ "...must contain: #{matcher.inspect}" end get def exclude! demand val.include?(matcher), "...can't contain #{matcher.inspect}" end get def matches_only! demand \ return!.reject { |val| val == matcher }.empty?, \ "...invalid elements: #{arr.inspect}" end end # === class Arrays end # === class Demand end # === class Checked
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
Checked-2.0.2 | lib/Checked/Demand/Arrays.rb |
Checked-2.0.1 | lib/Checked/Demand/Arrays.rb |
Checked-2.0.0 | lib/Checked/Demand/Arrays.rb |