Class: PortableExpressions::Scalar
- Inherits:
-
Object
- Object
- PortableExpressions::Scalar
- Includes:
- Serializable
- Defined in:
- lib/portable_expressions/scalar.rb
Overview
A ‘Scalar` is the simplest object that can be evaluated. It holds a single `value`. When used in an `Expression`, this `value` must respond to the symbol (i.e. support the method) defined by the `Expression#operator`.
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(value) ⇒ Scalar
constructor
A new instance of Scalar.
- #to_s ⇒ Object
Methods included from Serializable
Constructor Details
#initialize(value) ⇒ Scalar
Returns a new instance of Scalar.
11 12 13 |
# File 'lib/portable_expressions/scalar.rb', line 11 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
9 10 11 |
# File 'lib/portable_expressions/scalar.rb', line 9 def value @value end |
Instance Method Details
#as_json ⇒ Object
19 20 21 22 23 |
# File 'lib/portable_expressions/scalar.rb', line 19 def as_json super.merge( value: value ) end |
#to_s ⇒ Object
15 16 17 |
# File 'lib/portable_expressions/scalar.rb', line 15 def to_s value.to_s end |