Class: Archimate::DataModel::LangString

Inherits:
ArchimateNode
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/archimate/data_model/lang_string.rb

Overview

A base string type for multi-language strings.

Direct Known Subclasses

Documentation

Instance Attribute Summary

Attributes inherited from ArchimateNode

#parent_attribute_name, #struct_instance_variables

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ArchimateNode

#ancestors, #build_index, #clone, #compact!, #delete, #diff, #dup, #element_by_id, #id, #in_model, #in_model=, #initialize, #parent, #parent=, #path, #primitive?, #referenced_identified_nodes, #set, #with

Constructor Details

This class inherits a constructor from Archimate::DataModel::ArchimateNode

Class Method Details

.new(attributes) ⇒ Object

Parameters:

  • attributes (Hash{Symbol => Object}, Dry::Struct, String)

Raises:

  • (Struct::Error)

    if the given attributes don’t conform #schema with given #constructor_type



18
19
20
21
22
23
24
# File 'lib/archimate/data_model/lang_string.rb', line 18

def self.new(attributes)
  if attributes.instance_of?(String)
    super(text: attributes.strip)
  else
    super
  end
end

Instance Method Details

#=~(other) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/archimate/data_model/lang_string.rb', line 30

def =~(other)
  if other.is_a?(Regexp)
    other =~ @text
  else
    Regexp.new(Regexp.escape(@text)) =~ other
  end
end

#to_strObject



26
27
28
# File 'lib/archimate/data_model/lang_string.rb', line 26

def to_str
  @text
end