Sha256: 6d5515406179f23e4b13c0227643a231ac27a0f05fe8a13772b6de5f2d2af4e9

Contents?: true

Size: 734 Bytes

Versions: 1

Compression:

Stored size: 734 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 { |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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
csl-1.0.0.pre21 lib/csl/style/choose.rb