All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gems.sass-3.5.5.lib.sass.script.value.bool.rb Maven / Gradle / Ivy

There is a newer version: 3.7.2
Show newest version
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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy