Sha256: 7957bc18485bd3953aa3de951535a872e79b472ff74a6173c68d4885a09b0d7d

Contents?: true

Size: 1.01 KB

Versions: 46

Compression:

Stored size: 1.01 KB

Contents

module Sass::Script::Value
  # A SassScript object representing a boolean (true or false) value.
  class Bool < Base

    # The true value in SassScript.
    #
    # This is assigned before new is overridden below so that we use the default implementation.
    TRUE  = new(true)

    # The false value in SassScript.
    #
    # This is assigned before new is overridden below so that we use the default implementation.
    FALSE = new(false)

    # We override object creation so that users of the core API
    # will not need to know that booleans are specific constants.
    #
    # @param value A ruby value that will be tested for truthiness.
    # @return [Bool] TRUE if value is truthy, FALSE if value is falsey
    def self.new(value)
      value ? TRUE : FALSE
    end

    # The Ruby value of the boolean.
    #
    # @return [Boolean]
    attr_reader :value
    alias_method :to_bool, :value

    # @return [String] "true" or "false"
    def to_s(opts = {})
      @value.to_s
    end
    alias_method :to_sass, :to_s
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
sass-3.3.0.rc.2 lib/sass/script/value/bool.rb
sass-3.3.0.rc.1 lib/sass/script/value/bool.rb
sass-3.3.0.alpha.392 lib/sass/script/value/bool.rb
sass-3.3.0.alpha.391 lib/sass/script/value/bool.rb
sass-3.3.0.alpha.390 lib/sass/script/value/bool.rb
sass-3.3.0.alpha.389 lib/sass/script/value/bool.rb
sass-3.3.0.alpha.388 lib/sass/script/value/bool.rb
sass-3.3.0.alpha.382 lib/sass/script/value/bool.rb
sass-3.3.0.alpha.380 lib/sass/script/value/bool.rb
sass-3.3.0.alpha.378 lib/sass/script/value/bool.rb
sass-3.3.0.alpha.377 lib/sass/script/value/bool.rb
sass-3.3.0.alpha.376 lib/sass/script/value/bool.rb
sass-3.3.0.alpha.375 lib/sass/script/value/bool.rb
sass-3.3.0.alpha.372 lib/sass/script/value/bool.rb
sass-3.3.0.alpha.370 lib/sass/script/value/bool.rb
sass-3.3.0.alpha.369 lib/sass/script/value/bool.rb
sass-3.3.0.alpha.368 lib/sass/script/value/bool.rb
sass-3.3.0.alpha.367 lib/sass/script/value/bool.rb
sass-3.3.0.alpha.366 lib/sass/script/value/bool.rb
sass-3.3.0.alpha.364 lib/sass/script/value/bool.rb