Sha256: 0960a4922fd4f4b9d7b653e15215a1d5a766ad10acf8f43553557f17935134d7
Contents?: true
Size: 973 Bytes
Versions: 1
Compression:
Stored size: 973 Bytes
Contents
module CSL class Style class Choose < Node class Block < Node 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 do |name, values| extract_type_and_matcher_from(name) << values.to_s.split(/\s+/) end end def matcher(match = nil) match ||= attributes[:match] case match when 'any' :any? when 'none' :none? else :all? end end private def extract_type_and_matcher_from(attribute) type, match = attribute.to_s.split(/-(any|all|none)$/, 2) [type.to_sym, matcher(match)] end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
csl-1.0.0.pre22 | lib/csl/style/choose.rb |