Class: Ea::Svg::Parity::Source
- Inherits:
-
Object
- Object
- Ea::Svg::Parity::Source
- Defined in:
- lib/ea/svg/parity/source.rb
Overview
Loads an EA model Document from any supported source file
(.qea, .xmi). Used by the bench task to keep file-format
dispatch in one place.
Constant Summary collapse
- EXTENSIONS =
{ ".qea" => :qea, ".xmi" => :xmi }.freeze
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #document ⇒ Object
- #format ⇒ Object
-
#initialize(path) ⇒ Source
constructor
A new instance of Source.
- #load ⇒ Object
Constructor Details
#initialize(path) ⇒ Source
Returns a new instance of Source.
19 20 21 |
# File 'lib/ea/svg/parity/source.rb', line 19 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
17 18 19 |
# File 'lib/ea/svg/parity/source.rb', line 17 def path @path end |
Class Method Details
.detect(path) ⇒ Object
23 24 25 26 27 |
# File 'lib/ea/svg/parity/source.rb', line 23 def self.detect(path) ext = File.extname(path).downcase EXTENSIONS[ext] || raise(ArgumentError, "unsupported source: #{path} (ext=#{ext})") end |
Instance Method Details
#document ⇒ Object
36 37 38 |
# File 'lib/ea/svg/parity/source.rb', line 36 def document load end |
#format ⇒ Object
40 41 42 |
# File 'lib/ea/svg/parity/source.rb', line 40 def format self.class.detect(path) end |
#load ⇒ Object
29 30 31 32 33 34 |
# File 'lib/ea/svg/parity/source.rb', line 29 def load case self.class.detect(path) when :qea then load_qea when :xmi then load_xmi end end |