Sha256: b888a5fc033ce3371a186c035608b81a15b3eb9f5e6362a77633aaef7a79c388

Contents?: true

Size: 1.33 KB

Versions: 25

Compression:

Stored size: 1.33 KB

Contents

module Less
  #
  # Node::Entity
  #   
  #   Everything in the tree is an Entity
  #
  # Mixin/Class hierarchy
  #
  # - Entity
  #   - Element
  #   - Entity
  #     - Function
  #     - Keyword
  #     - Literal
  #       - Color
  #       - Number
  #       - String
  #       - FontFamily
  #   - Property
  #     - Variable
  #
  # TODO: Use delegate class -> @rules
  #
  module Node
    module Entity
      attr_accessor :parent
    
      def initialize value, parent = nil
        super value
        @parent = parent
      end
      
      #
      # Returns the path from any given node, to the root
      #
      #   ex: ['color', 'p', '#header', 'body', '*']
      #
      def path node = self
        path = []
        while node do
          path << node
          node = node.parent
        end
        path
      end
    
      def root
        path.last
      end
    
      def inspect;  to_s  end
      def to_css;   to_s  end
      def to_s;     super end
    end
    
    #
    # An anonymous node, for all the 'other' stuff
    # which doesn't need any specific functionality.
    #
    class Anonymous < String
      include Entity
    end
    
    #
    # + * - /
    #
    class Operator < String
      def to_ruby
        self
      end
    end
    
    class Paren < String
      def to_ruby
        self
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 5 rubygems

Version Path
cloudhead-less-1.2.0 lib/less/engine/nodes/entity.rb
cloudhead-less-1.2.1 lib/less/engine/nodes/entity.rb
cloudhead-less-1.2.2 lib/less/engine/nodes/entity.rb
cloudhead-less-1.2.3 lib/less/engine/nodes/entity.rb
cloudhead-less-1.2.4 lib/less/engine/nodes/entity.rb
cloudhead-less-1.2.5 lib/less/engine/nodes/entity.rb
cloudhead-less-1.2.7 lib/less/engine/nodes/entity.rb
cloudhead-less-1.2.8 lib/less/engine/nodes/entity.rb
lesslateral-1.2.21 lib/less/engine/nodes/entity.rb
less-1.2.21 lib/less/engine/nodes/entity.rb
less-1.2.20 lib/less/engine/nodes/entity.rb
unboxed-less-1.2.19 lib/less/engine/nodes/entity.rb
railsdog-less-1.2.17 lib/less/engine/nodes/entity.rb
less-1.2.19 lib/less/engine/nodes/entity.rb
less-1.2.18 lib/less/engine/nodes/entity.rb
less-1.2.17 lib/less/engine/nodes/entity.rb
less-1.2.16 lib/less/engine/nodes/entity.rb
less-1.2.15 lib/less/engine/nodes/entity.rb
less-1.2.14 lib/less/engine/nodes/entity.rb
less-1.2.13 lib/less/engine/nodes/entity.rb