Class: Odca::Overlays::LabelOverlay
- Inherits:
-
Object
- Object
- Odca::Overlays::LabelOverlay
- Defined in:
- lib/odca/overlays/label_overlay.rb
Defined Under Namespace
Classes: CategoryResolver, InputValidator, LabelAttribute
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#category_resolver ⇒ Object
readonly
Returns the value of attribute category_resolver.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
Instance Method Summary collapse
- #add_attribute(attribute) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(language:, category_resolver: CategoryResolver.new) ⇒ LabelOverlay
constructor
A new instance of LabelOverlay.
- #to_h ⇒ Object
Constructor Details
#initialize(language:, category_resolver: CategoryResolver.new) ⇒ LabelOverlay
Returns a new instance of LabelOverlay.
8 9 10 11 12 |
# File 'lib/odca/overlays/label_overlay.rb', line 8 def initialize(language:, category_resolver: CategoryResolver.new) @attributes = [] @language = language @category_resolver = category_resolver end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
6 7 8 |
# File 'lib/odca/overlays/label_overlay.rb', line 6 def attributes @attributes end |
#category_resolver ⇒ Object (readonly)
Returns the value of attribute category_resolver.
6 7 8 |
# File 'lib/odca/overlays/label_overlay.rb', line 6 def category_resolver @category_resolver end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
6 7 8 |
# File 'lib/odca/overlays/label_overlay.rb', line 6 def language @language end |
Instance Method Details
#add_attribute(attribute) ⇒ Object
29 30 31 32 |
# File 'lib/odca/overlays/label_overlay.rb', line 29 def add_attribute(attribute) return if attribute.nil? || attribute.attr_name.strip.empty? attributes << attribute end |
#empty? ⇒ Boolean
25 26 27 |
# File 'lib/odca/overlays/label_overlay.rb', line 25 def empty? attributes.empty? end |
#to_h ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/odca/overlays/label_overlay.rb', line 14 def to_h resolved_categories = category_resolver.call(attributes) { language: language, attr_labels: attr_labels, attr_categories: resolved_categories.attr_categories, cat_labels: resolved_categories.category_labels, cat_attributes: resolved_categories.category_attributes } end |