dart-sass/lib/src/value/boolean.dart

29 lines
771 B
Dart
Raw Normal View History

2016-05-25 05:01:43 +02:00
// Copyright 2016 Google Inc. Use of this source code is governed by an
// MIT-style license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
2016-08-15 08:51:29 +02:00
import '../visitor/interface/value.dart';
2016-05-25 05:01:43 +02:00
import '../value.dart';
2016-06-04 01:31:29 +02:00
const sassTrue = const SassBoolean._(true);
const sassFalse = const SassBoolean._(false);
2016-05-25 05:01:43 +02:00
2016-06-04 01:31:29 +02:00
class SassBoolean extends Value {
2016-05-25 05:01:43 +02:00
final bool value;
2016-08-28 23:26:40 +02:00
bool get isTruthy => value;
2016-06-04 01:31:29 +02:00
factory SassBoolean(bool value) => value ? sassTrue : sassFalse;
2016-05-25 05:01:43 +02:00
2016-06-04 01:31:29 +02:00
const SassBoolean._(this.value);
2016-05-25 05:01:43 +02:00
2016-05-28 01:09:03 +02:00
/*=T*/ accept/*<T>*/(ValueVisitor/*<T>*/ visitor) =>
visitor.visitBoolean(this);
2016-09-19 17:50:39 +02:00
Value or(Value other) => value ? this : other;
Value and(Value other) => value ? other : this;
2016-05-25 05:01:43 +02:00
Value unaryNot() => value ? sassFalse : sassTrue;
}