Sha256: a0cd5a566896dc4a64bb5585b99dab174da58d8d3db1bd291a7b25b5350b42df

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

module CSL
  
  class Style < Node
    
    @default = :apa

    @root = File.expand_path('../../../vendor/styles', __FILE__).freeze
        
    @extension = '.csl'.freeze
    @prefix = ''
    
    class << self
      include Loader
      
      attr_accessor :default

      def parse(data)
        node = CSL.parse!(data, self)
        
        raise ParseError, "root node is not a style: #{node.inspect}" unless
          node.is_a?(self)
        
        node
      end
    end
    
    attr_defaults :version => Schema.version, :xmlns => Schema.namespace
    
    attr_struct :xmlns, :version, :class, :'default-locale',
      :'initialize-with-hyphen', :'page-range-format',
      :'demote-non-dropping-particle', *Schema.attr(:name, :names)
    
    attr_children :'style-options', :info, :locale, :macro,
      :citation, :bibliography
    
    alias metadata info
    alias options  style_options
    alias locales  locale
    
    def initialize(attributes = {})
      super(attributes)
      
      children[:locale] = []
      children[:macro]  = []
      
      yield self if block_given?
    end

    def validate
      Schema.validate self
    end
    
    def valid?
      validate.empty?
    end
    
    private
    
    def preamble
      Schema.preamble.dup
    end 
  end
    
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
csl-1.0.0.pre2 lib/csl/style.rb