class Bliss::Constraint
Attributes
depth[RW]
possible_values[RW]
setting[R]
state[R]
Public Class Methods
new(depth, setting, params={})
click to toggle source
# File lib/bliss/constraint.rb, line 6 def initialize(depth, setting, params={}) @depth = depth @setting = setting @possible_values = params[:possible_values].collect(&:to_s) if params.has_key?(:possible_values) @state = :not_checked end
Public Instance Methods
detail()
click to toggle source
# File lib/bliss/constraint.rb, line 84 def detail self.ended! # TODO esto es una chota de codigo groncho! case @state when :not_passed case @setting when :tag_name_required [@depth, "missing"] #when :not_blank # [@field.join(" or "), "blank"] #when :possible_values # [@field.join(" or "), "invalid"] end when :passed case @setting when :tag_name_required [@depth, "exists"] end end end
ended!()
click to toggle source
# File lib/bliss/constraint.rb, line 75 def ended! case @setting when :tag_name_required if @state == :not_checked @state = :not_passed end end end
run!(hash=nil)
click to toggle source
TODO should exist another method passed! for tag_name_required ?
# File lib/bliss/constraint.rb, line 19 def run!(hash=nil) @state = :not_checked #@field.each do |field| #if @state == :passed # break #end case @setting when :tag_name_required content = nil if hash #puts "#{@depth.inspect} - required: #{required.inspect}" found = false self.tag_names.each do |key| if hash.keys.include?(key) found = true break end end if found @state = :passed else @state = :not_passed end else @state = :passed end when :content_values if hash found = false self.tag_names.each do |key| content = hash[key] puts content puts @possible_values.inspect if @possible_values.include?(content) found = true break end end if found @state = :passed else @state = :not_passed end end #when :not_blank # if hash.has_key?(field) and !hash[field].to_s.empty? # @state = :passed # else # @state = :not_passed # end end #end @state end
tag_names()
click to toggle source
# File lib/bliss/constraint.rb, line 14 def tag_names @depth.split('/').last.gsub('(', '').gsub(')', '').split('|') end