Sha256: d5f2ed96bf44f1324ec3271d2c7ea5b6703e37471f8599fbb0ca93b99344cfb1

Contents?: true

Size: 1.1 KB

Versions: 15

Compression:

Stored size: 1.1 KB

Contents

module Sass
  module Tree
    class Node
      attr_accessor :children
      attr_accessor :line
      attr_accessor :filename

      def initialize(style)
        @style = style
        @children = []
      end

      def <<(child)
        if msg = invalid_child?(child)
          raise Sass::SyntaxError.new(msg, child.line)
        end
        @children << child
      end

      def ==(other)
        self.class == other.class && other.children == children
      end

      def to_s
        result = String.new
        children.each do |child|
          if child.is_a? AttrNode
            raise SyntaxError.new('Attributes aren\'t allowed at the root of a document.', child.line)
          else
            result << "#{child.to_s(1)}" + (@style == :compressed ? '' : "\n")
          end
        end
        @style == :compressed ? result+"\n" : result[0...-1]
      end

      private

      # This method should be overridden by subclasses to return an error message
      # if the given child node is invalid,
      # and false or nil otherwise.
      def invalid_child?(child)
        false
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 4 rubygems

Version Path
radiantcms-couchrest_model-0.2.4 vendor/plugins/haml/lib/sass/tree/node.rb
radiantcms-couchrest_model-0.2.2 vendor/plugins/haml/lib/sass/tree/node.rb
radiantcms-couchrest_model-0.2.1 vendor/plugins/haml/lib/sass/tree/node.rb
radiantcms-couchrest_model-0.2 vendor/plugins/haml/lib/sass/tree/node.rb
radiantcms-couchrest_model-0.1.9 vendor/plugins/haml/lib/sass/tree/node.rb
radiantcms-couchrest_model-0.1.8 vendor/plugins/haml/lib/sass/tree/node.rb
radiantcms-couchrest_model-0.1.7 vendor/plugins/haml/lib/sass/tree/node.rb
radiantcms-couchrest_model-0.1.6 vendor/plugins/haml/lib/sass/tree/node.rb
radiantcms-couchrest_model-0.1.5 vendor/plugins/haml/lib/sass/tree/node.rb
radiant-0.8.2 vendor/plugins/haml/lib/sass/tree/node.rb
radiant-rc-0.9.0 vendor/plugins/haml/lib/sass/tree/node.rb
radiant-0.8.1 vendor/plugins/haml/lib/sass/tree/node.rb
haml-2.0.10 lib/sass/tree/node.rb
haml-2.0.9 lib/sass/tree/node.rb
radiant-0.8.0 vendor/plugins/haml/lib/sass/tree/node.rb