Sha256: 72cd372546c925e50fcfcc7aaf37c6bec72525245e559f19ab37b7505f8b0568

Contents?: true

Size: 1.29 KB

Versions: 137

Compression:

Stored size: 1.29 KB

Contents

require 'sass/tree/node'

module Sass::Tree
  # A dynamic node representing a Sass `@if` statement.
  #
  # {IfNode}s are a little odd, in that they also represent `@else` and `@else if`s.
  # This is done as a linked list:
  # each {IfNode} has a link (\{#else}) to the next {IfNode}.
  #
  # @see Sass::Tree
  class IfNode < Node
    # The conditional expression.
    # If this is nil, this is an `@else` node, not an `@else if`.
    #
    # @return [Script::Expr]
    attr_accessor :expr

    # The next {IfNode} in the if-else list, or `nil`.
    #
    # @return [IfNode]
    attr_accessor :else

    # @param expr [Script::Expr] See \{#expr}
    def initialize(expr)
      @expr = expr
      @last_else = self
      super()
    end

    # Append an `@else` node to the end of the list.
    #
    # @param node [IfNode] The `@else` node to append
    def add_else(node)
      @last_else.else = node
      @last_else = node
    end

    def _dump(f)
      Marshal.dump([expr, self.else, children])
    end

    def self._load(data)
      expr, else_, children = Marshal.load(data)
      node = IfNode.new(expr)
      node.else = else_
      node.children = children
      node.instance_variable_set('@last_else',
        node.else ? node.else.instance_variable_get('@last_else') : node)
      node
    end
  end
end

Version data entries

137 entries across 134 versions & 9 rubygems

Version Path
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/if_node.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/sass-3.7.4/lib/sass/tree/if_node.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/sass-3.7.4/lib/sass/tree/if_node.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/sass-3.7.4/lib/sass/tree/if_node.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/sass-3.7.4/lib/sass/tree/if_node.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/sass-3.7.4/lib/sass/tree/if_node.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/sass-3.7.4/lib/sass/tree/if_node.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/sass-3.7.4/lib/sass/tree/if_node.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/sass-3.7.4/lib/sass/tree/if_node.rb
zuora_connect_ui-0.8.1 vendor/ruby/2.6.0/gems/sass-3.7.4/lib/sass/tree/if_node.rb
zuora_connect_ui-0.8.0 vendor/ruby/2.6.0/gems/sass-3.7.4/lib/sass/tree/if_node.rb
zuora_connect_ui-0.7.1 vendor/ruby/2.6.0/gems/sass-3.7.4/lib/sass/tree/if_node.rb
zuora_connect_ui-0.7.0 vendor/ruby/2.6.0/gems/sass-3.7.4/lib/sass/tree/if_node.rb
sass-3.7.4 lib/sass/tree/if_node.rb
brakeman-4.4.0 bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/if_node.rb
sass-3.7.3 lib/sass/tree/if_node.rb
sass-3.7.2 lib/sass/tree/if_node.rb
sass-3.7.1 lib/sass/tree/if_node.rb
sass-3.7.0 lib/sass/tree/if_node.rb
sass-3.6.0 lib/sass/tree/if_node.rb