Class: PortableExpressions::Variable

Inherits:
Object
  • Object
show all
Includes:
Serializable
Defined in:
lib/portable_expressions/variable.rb

Overview

A ‘Variable` represents a named value stored in the `Environment`. Unlike `Scalars`, `Variables` have no value until they are evaluated by an `Environment`. Evaluating a `Variable` that isn’t present in the ‘Environment` will result in a `MissingVariableError`.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Serializable

#to_json

Constructor Details

#initialize(name) ⇒ Variable

Returns a new instance of Variable.



12
13
14
# File 'lib/portable_expressions/variable.rb', line 12

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/portable_expressions/variable.rb', line 10

def name
  @name
end

Instance Method Details

#as_jsonObject



20
21
22
23
24
# File 'lib/portable_expressions/variable.rb', line 20

def as_json
  super.merge(
    name: name
  )
end

#to_sObject



16
17
18
# File 'lib/portable_expressions/variable.rb', line 16

def to_s
  name
end