Class: Archimate::FileFormats::Sax::Handler
- Inherits:
-
Object
- Object
- Archimate::FileFormats::Sax::Handler
- Defined in:
- lib/archimate/file_formats/sax/handler.rb
Direct Known Subclasses
AnyElement, Archi::Bounds, Archi::Connection, Archi::Content, Archi::Diagram, Archi::Element, Archi::Location, Archi::Model, Archi::Organization, Archi::Property, Archi::Relationship, Archi::ViewNode, ContentElement, LangString, ModelExchangeFile::Color, ModelExchangeFile::Connection, ModelExchangeFile::Diagram, ModelExchangeFile::Element, ModelExchangeFile::Font, ModelExchangeFile::Item, ModelExchangeFile::Location, ModelExchangeFile::Metadata, ModelExchangeFile::Model, ModelExchangeFile::Property, ModelExchangeFile::PropertyDefinition, ModelExchangeFile::Relationship, ModelExchangeFile::SchemaInfo, ModelExchangeFile::Style, ModelExchangeFile::ViewNode, NoOp, PreservedLangString
Instance Attribute Summary collapse
-
#attrs ⇒ Object
readonly
Returns the value of attribute attrs.
-
#element_type ⇒ Object
readonly
Returns the value of attribute element_type.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent_handler ⇒ Object
readonly
Returns the value of attribute parent_handler.
Instance Method Summary collapse
- #characters(string) ⇒ Object
-
#complete ⇒ Array<Event>
Array of events to fire for this handler.
- #diagram ⇒ Object
- #event(sym, args) ⇒ Object
-
#initialize(name, attrs, parent_handler) ⇒ Handler
constructor
A new instance of Handler.
- #method_missing(sym, *args) ⇒ Object
- #process_text(str) ⇒ Object
-
#property_definitions ⇒ Object
Returns the property definitions hash for this SaxDocument.
- #respond_to_missing?(symbol, _include_all) ⇒ Boolean
Constructor Details
#initialize(name, attrs, parent_handler) ⇒ Handler
Returns a new instance of Handler.
12 13 14 15 16 17 |
# File 'lib/archimate/file_formats/sax/handler.rb', line 12 def initialize(name, attrs, parent_handler) @name = name @attrs = Hash[attrs] @parent_handler = parent_handler @element_type = @attrs["xsi:type"]&.sub(/archimate:/, '') end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
34 35 36 37 |
# File 'lib/archimate/file_formats/sax/handler.rb', line 34 def method_missing(sym, *args) return args.first if sym.to_s.start_with?("on_") super end |
Instance Attribute Details
#attrs ⇒ Object (readonly)
Returns the value of attribute attrs.
8 9 10 |
# File 'lib/archimate/file_formats/sax/handler.rb', line 8 def attrs @attrs end |
#element_type ⇒ Object (readonly)
Returns the value of attribute element_type.
10 11 12 |
# File 'lib/archimate/file_formats/sax/handler.rb', line 10 def element_type @element_type end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/archimate/file_formats/sax/handler.rb', line 7 def name @name end |
#parent_handler ⇒ Object (readonly)
Returns the value of attribute parent_handler.
9 10 11 |
# File 'lib/archimate/file_formats/sax/handler.rb', line 9 def parent_handler @parent_handler end |
Instance Method Details
#characters(string) ⇒ Object
19 |
# File 'lib/archimate/file_formats/sax/handler.rb', line 19 def characters(string); end |
#complete ⇒ Array<Event>
Returns array of events to fire for this handler.
22 23 24 |
# File 'lib/archimate/file_formats/sax/handler.rb', line 22 def complete [] end |
#diagram ⇒ Object
26 27 28 |
# File 'lib/archimate/file_formats/sax/handler.rb', line 26 def diagram parent_handler&.diagram end |
#event(sym, args) ⇒ Object
30 31 32 |
# File 'lib/archimate/file_formats/sax/handler.rb', line 30 def event(sym, args) SaxEvent.new(sym, args, self) end |
#process_text(str) ⇒ Object
48 49 50 |
# File 'lib/archimate/file_formats/sax/handler.rb', line 48 def process_text(str) str&.gsub("&", "&") end |
#property_definitions ⇒ Object
Returns the property definitions hash for this SaxDocument
44 45 46 |
# File 'lib/archimate/file_formats/sax/handler.rb', line 44 def property_definitions parent_handler&.property_definitions || [] end |
#respond_to_missing?(symbol, _include_all) ⇒ Boolean
39 40 41 |
# File 'lib/archimate/file_formats/sax/handler.rb', line 39 def respond_to_missing?(symbol, _include_all) symbol.to_s.start_with?("on_") end |