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.
21 22 23 |
# File 'lib/ea/svg/parity/source.rb', line 21 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
19 20 21 |
# File 'lib/ea/svg/parity/source.rb', line 19 def path @path end |
Class Method Details
.detect(path) ⇒ Object
25 26 27 28 29 |
# File 'lib/ea/svg/parity/source.rb', line 25 def self.detect(path) ext = File.extname(path).downcase EXTENSIONS[ext] || raise(ArgumentError, "unsupported source: #{path} (ext=#{ext})") end |
Instance Method Details
#document ⇒ Object
38 39 40 |
# File 'lib/ea/svg/parity/source.rb', line 38 def document load end |
#format ⇒ Object
42 43 44 |
# File 'lib/ea/svg/parity/source.rb', line 42 def format self.class.detect(path) end |
#load ⇒ Object
31 32 33 34 35 36 |
# File 'lib/ea/svg/parity/source.rb', line 31 def load case self.class.detect(path) when :qea then load_qea when :xmi then load_xmi end end |