Class: SimpleInlineTextAnnotation::EntityTypeCollection
- Inherits:
-
Object
- Object
- SimpleInlineTextAnnotation::EntityTypeCollection
- Defined in:
- lib/simple_inline_text_annotation/entity_type_collection.rb
Instance Method Summary collapse
- #any? ⇒ Boolean
-
#get(label) ⇒ Object
get returns the entity type id for a given label.
-
#initialize(source) ⇒ EntityTypeCollection
constructor
A new instance of EntityTypeCollection.
-
#to_config ⇒ Object
to_config returns a Array of hashes of each entity type.
Constructor Details
#initialize(source) ⇒ EntityTypeCollection
Returns a new instance of EntityTypeCollection.
5 6 7 |
# File 'lib/simple_inline_text_annotation/entity_type_collection.rb', line 5 def initialize(source) @source = source end |
Instance Method Details
#any? ⇒ Boolean
32 33 34 |
# File 'lib/simple_inline_text_annotation/entity_type_collection.rb', line 32 def any? entity_types.any? end |
#get(label) ⇒ Object
get returns the entity type id for a given label. Example:
get("Person") => "https://example.com/Person"
If the label is not found, it returns nil. Example:
get("NonExistentLabel") => nil
16 17 18 |
# File 'lib/simple_inline_text_annotation/entity_type_collection.rb', line 16 def get(label) entity_types[label] end |
#to_config ⇒ Object
to_config returns a Array of hashes of each entity type. Example:
[
{id: "https://example.com/Person", label: "Person"},
{id: "https://example.com/Organization", label: "Organization"}
]
26 27 28 29 30 |
# File 'lib/simple_inline_text_annotation/entity_type_collection.rb', line 26 def to_config entity_types.map do |label, id| { id: id, label: label } end end |