Class: Perforated::Rebuilder
- Inherits:
-
Object
- Object
- Perforated::Rebuilder
- Defined in:
- lib/perforated/rebuilder.rb
Instance Attribute Summary collapse
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
-
#strings ⇒ Object
readonly
Returns the value of attribute strings.
Instance Method Summary collapse
- #concatenated ⇒ Object
-
#initialize(strings, parser = Perforated.json) ⇒ Rebuilder
constructor
A new instance of Rebuilder.
- #rebuild(rooted: false) ⇒ Object
Constructor Details
#initialize(strings, parser = Perforated.json) ⇒ Rebuilder
Returns a new instance of Rebuilder.
7 8 9 10 |
# File 'lib/perforated/rebuilder.rb', line 7 def initialize(strings, parser = Perforated.json) @strings = strings @parser = parser end |
Instance Attribute Details
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
5 6 7 |
# File 'lib/perforated/rebuilder.rb', line 5 def parser @parser end |
#strings ⇒ Object (readonly)
Returns the value of attribute strings.
5 6 7 |
# File 'lib/perforated/rebuilder.rb', line 5 def strings @strings end |
Instance Method Details
#concatenated ⇒ Object
20 21 22 |
# File 'lib/perforated/rebuilder.rb', line 20 def concatenated "[#{strings.join(',')}]" end |
#rebuild(rooted: false) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/perforated/rebuilder.rb', line 12 def rebuild(rooted: false) if rooted parser.dump(merge(parser.load(concatenated))) else concatenated end end |