Class: Transit::WriteHandlers::MapHandler
- Inherits:
-
Object
- Object
- Transit::WriteHandlers::MapHandler
- Defined in:
- lib/transit/write_handlers.rb
Instance Method Summary collapse
- #handlers=(handlers) ⇒ Object
- #rep(m) ⇒ Object
- #string_rep(_) ⇒ Object
- #stringable_keys?(m) ⇒ Boolean
- #tag(m) ⇒ Object
Instance Method Details
#handlers=(handlers) ⇒ Object
381 382 383 |
# File 'lib/transit/write_handlers.rb', line 381 def handlers=(handlers) @handlers = handlers end |
#rep(m) ⇒ Object
393 394 395 |
# File 'lib/transit/write_handlers.rb', line 393 def rep(m) stringable_keys?(m) ? m : m.reduce([]) {|a, kv| a.concat(kv)} end |
#string_rep(_) ⇒ Object
397 |
# File 'lib/transit/write_handlers.rb', line 397 def string_rep(_) nil end |
#stringable_keys?(m) ⇒ Boolean
385 386 387 |
# File 'lib/transit/write_handlers.rb', line 385 def stringable_keys?(m) m.keys.all? {|k| (@handlers[k.class].tag(k).length == 1) } end |
#tag(m) ⇒ Object
389 390 391 |
# File 'lib/transit/write_handlers.rb', line 389 def tag(m) stringable_keys?(m) ? "map" : "cmap" end |