Class: PgVerify::Model::Assignment
- Inherits:
-
Object
- Object
- PgVerify::Model::Assignment
- Defined in:
- lib/pg-verify/model/assignment.rb
Constant Summary collapse
- ASSIGN_OPERATOR =
':='
Instance Attribute Summary collapse
-
#assigned_variable ⇒ Object
The name of the variable which is assigned a value.
-
#expression ⇒ Object
The Model::Expression which of this assignment.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(assigned_variable, expression) ⇒ Assignment
constructor
A new instance of Assignment.
- #to_s ⇒ Object
Constructor Details
#initialize(assigned_variable, expression) ⇒ Assignment
Returns a new instance of Assignment.
23 24 25 |
# File 'lib/pg-verify/model/assignment.rb', line 23 def initialize(assigned_variable, expression) @assigned_variable, @expression = assigned_variable, expression end |
Instance Attribute Details
#assigned_variable ⇒ Object
The name of the variable which is assigned a value
10 11 12 |
# File 'lib/pg-verify/model/assignment.rb', line 10 def assigned_variable @assigned_variable end |
#expression ⇒ Object
The Model::Expression which of this assignment
13 14 15 |
# File 'lib/pg-verify/model/assignment.rb', line 13 def expression @expression end |
Class Method Details
.from_string(string) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/pg-verify/model/assignment.rb', line 15 def self.from_string(string) raise "Not an assignment: #{string}" unless string.include?(ASSIGN_OPERATOR) split = string.split(ASSIGN_OPERATOR).map(&:strip) assigned_variable = split[0].to_sym expression = Expression.from_string(split[1]) return Assignment.new(assigned_variable, expression) end |
Instance Method Details
#to_s ⇒ Object
27 28 29 |
# File 'lib/pg-verify/model/assignment.rb', line 27 def to_s() return "#{assigned_variable} #{ASSIGN_OPERATOR} #{expression.to_s}" end |