Class: NeoScout::Constraints::PropConstraint
- Inherits:
-
Constraint
- Object
- Constraint
- NeoScout::Constraints::PropConstraint
- Defined in:
- lib/neoscout/constraints.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#opt ⇒ Object
readonly
Returns the value of attribute opt.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ PropConstraint
constructor
A new instance of PropConstraint.
- #to_s ⇒ Object
Methods inherited from Constraint
#satisfied_by?, #satisfied_by_edge?, #satisfied_by_node?
Constructor Details
#initialize(args = {}) ⇒ PropConstraint
Returns a new instance of PropConstraint.
15 16 17 18 19 20 21 22 23 |
# File 'lib/neoscout/constraints.rb', line 15 def initialize(args = {}) super(args) @name = args[:name] @opt = args[:opt] @type = args[:type] raise ArgumentError unless @name.kind_of? String raise ArgumentError unless @name.length > 0 end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/neoscout/constraints.rb', line 13 def name @name end |
#opt ⇒ Object (readonly)
Returns the value of attribute opt.
13 14 15 |
# File 'lib/neoscout/constraints.rb', line 13 def opt @opt end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
13 14 15 |
# File 'lib/neoscout/constraints.rb', line 13 def type @type end |
Instance Method Details
#to_s ⇒ Object
25 26 27 28 29 30 |
# File 'lib/neoscout/constraints.rb', line 25 def to_s opt_s = if @opt then " (opt.)" else '' end type_s = if @type then ": #{@type}" else '' end "#{@name}#{type_s}#{opt_s}" end |