Class: Odca::Overlays::LabelOverlay::InputValidator
- Inherits:
-
Object
- Object
- Odca::Overlays::LabelOverlay::InputValidator
- Defined in:
- lib/odca/overlays/label_overlay.rb
Instance Attribute Summary collapse
-
#attr_name ⇒ Object
readonly
Returns the value of attribute attr_name.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(attr_name:, value:) ⇒ InputValidator
constructor
A new instance of InputValidator.
Constructor Details
#initialize(attr_name:, value:) ⇒ InputValidator
Returns a new instance of InputValidator.
119 120 121 122 123 124 125 126 |
# File 'lib/odca/overlays/label_overlay.rb', line 119 def initialize(attr_name:, value:) if attr_name.strip.empty? raise 'Attribute name is expected to be non empty String' end @attr_name = attr_name @value = value end |
Instance Attribute Details
#attr_name ⇒ Object (readonly)
Returns the value of attribute attr_name.
117 118 119 |
# File 'lib/odca/overlays/label_overlay.rb', line 117 def attr_name @attr_name end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
117 118 119 |
# File 'lib/odca/overlays/label_overlay.rb', line 117 def value @value end |
Instance Method Details
#call ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/odca/overlays/label_overlay.rb', line 128 def call splited = value.split('|').map(&:strip) label = splited.empty? ? Odca::NullValue.new : splited.pop categories = splited { attr_name: attr_name.strip, categories: categories, label: label } end |