Class: Marathon::Constraint
Overview
This class represents a Marathon Constraint. See mesosphere.github.io/marathon/docs/constraints.html for full details.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #attribute ⇒ Object
-
#initialize(array) ⇒ Constraint
constructor
Create a new constraint object.
- #operator ⇒ Object
- #parameter ⇒ Object
-
#to_pretty_s ⇒ Object
Returns a string for listing the constraint.
- #to_s ⇒ Object
Methods inherited from Base
Methods included from Error
error_class, error_message, from_response
Constructor Details
#initialize(array) ⇒ Constraint
Create a new constraint object. array
: Array returned by API, holds attribute, operator and parameter.
7 8 9 10 11 12 13 |
# File 'lib/marathon/constraint.rb', line 7 def initialize(array) raise Marathon::Error::ArgumentError, 'array must be an Array' unless array.is_a?(Array) raise Marathon::Error::ArgumentError, 'array must be [attribute, operator, parameter] where only parameter is optional' \ unless array.size != 2 or array.size != 3 super end |
Instance Method Details
#attribute ⇒ Object
15 16 17 |
# File 'lib/marathon/constraint.rb', line 15 def attribute info[0] end |
#operator ⇒ Object
19 20 21 |
# File 'lib/marathon/constraint.rb', line 19 def operator info[1] end |
#parameter ⇒ Object
23 24 25 |
# File 'lib/marathon/constraint.rb', line 23 def parameter info[2] end |
#to_pretty_s ⇒ Object
Returns a string for listing the constraint.
36 37 38 |
# File 'lib/marathon/constraint.rb', line 36 def to_pretty_s info.join(':') end |
#to_s ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/marathon/constraint.rb', line 27 def to_s if parameter "Marathon::Constraint { :attribute => #{attribute} :operator => #{operator} :parameter => #{parameter} }" else "Marathon::Constraint { :attribute => #{attribute} :operator => #{operator} }" end end |