Class: TranslationDiff::Document
- Inherits:
-
Object
- Object
- TranslationDiff::Document
- Defined in:
- lib/translation_diff/document.rb
Overview
A caller's value together with its Hash/Array shape, walked without ever flattening it into an array.
Instance Method Summary collapse
-
#initialize(value) ⇒ Document
constructor
A new instance of Document.
-
#map ⇒ Object
Returns a new structure of the same shape with every leaf String replaced by the block's result.
-
#strings ⇒ Object
Returns the leaf strings in document order, without touching the original value.
Constructor Details
#initialize(value) ⇒ Document
Returns a new instance of Document.
3 |
# File 'lib/translation_diff/document.rb', line 3 def initialize(value) = @value = value |
Instance Method Details
#map ⇒ Object
Returns a new structure of the same shape with every leaf String replaced by the block's result.
6 |
# File 'lib/translation_diff/document.rb', line 6 def map(&) = walk(@value, &) |
#strings ⇒ Object
Returns the leaf strings in document order, without touching the original value.
9 10 11 |
# File 'lib/translation_diff/document.rb', line 9 def strings [].tap { |acc| walk(@value) { |string| acc << string } } end |