lib/csl/style/choose.rb in csl-1.0.0.pre20 vs lib/csl/style/choose.rb in csl-1.0.0.pre21
- old
+ new
@@ -1,16 +1,37 @@
module CSL
class Style
-
+
class Choose < Node
class Block < Node
-
- def self.matches?(nodename)
- nodename.to_s =~ /^if(-else)?|else$/
+ attr_struct :match, *Schema.attr(:conditionals)
+
+ attr_defaults :match => 'all'
+
+ class << self
+ def matches?(nodename)
+ nodename.to_s =~ /^if(-else)?|else$/
+ end
end
+ def conditions
+ attributes_for(*Schema.attr(:conditionals)).map { |type, values|
+ values.to_s.split(/\s+/).map { |value| [type, value] }
+ }.flatten(1)
+ end
+
+ def matcher
+ case attributes[:match]
+ when 'any'
+ :any?
+ when 'none'
+ :none?
+ else
+ :all?
+ end
+ end
end
end
-
+
end
end
\ No newline at end of file