Class: Charta::Factory::Transformers::EwktTransformerChain
- Inherits:
-
EwktTransformer
- Object
- EwktTransformer
- Charta::Factory::Transformers::EwktTransformerChain
- Defined in:
- lib/charta/factory/transformers/ewkt_transformer_chain.rb
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
- #handles?(value, format:) ⇒ Boolean
-
#initialize(*transformers) ⇒ EwktTransformerChain
constructor
A new instance of EwktTransformerChain.
-
#transform(value, srid: nil, format: nil) ⇒ String
Ewkt representation of value.
Constructor Details
#initialize(*transformers) ⇒ EwktTransformerChain
Returns a new instance of EwktTransformerChain.
22 23 24 |
# File 'lib/charta/factory/transformers/ewkt_transformer_chain.rb', line 22 def initialize(*transformers) @transformers = transformers end |
Instance Attribute Details
#transformers ⇒ Array<EwktTransformer> (readonly)
20 21 22 |
# File 'lib/charta/factory/transformers/ewkt_transformer_chain.rb', line 20 def transformers @transformers end |
Class Method Details
.build ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/charta/factory/transformers/ewkt_transformer_chain.rb', line 8 def build new( Transformers::FromGeoJsonTransformer.new, Transformers::FromWkbTransformer.new, Transformers::FromGmlTransformer.new, Transformers::FromKmlTransformer.new, Transformers::EwktPassthrough.new ) end |
Instance Method Details
#handles?(value, format:) ⇒ Boolean
27 28 29 |
# File 'lib/charta/factory/transformers/ewkt_transformer_chain.rb', line 27 def handles?(value, format:) transformers.any? { |t| t.handles?(value, format: format) } end |
#transform(value, srid: nil, format: nil) ⇒ String
Returns ewkt representation of value.
33 34 35 36 37 38 |
# File 'lib/charta/factory/transformers/ewkt_transformer_chain.rb', line 33 def transform(value, srid: nil, format: nil) transformer = transformers.detect { |t| t.handles?(value, format: format) } raise TransformationError.new('Not handled') if transformer.nil? transformer.transform(value, srid: srid, format: format) end |