Class: Perforated::Rebuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/perforated/rebuilder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#parserObject (readonly)

Returns the value of attribute parser.



5
6
7
# File 'lib/perforated/rebuilder.rb', line 5

def parser
  @parser
end

#stringsObject (readonly)

Returns the value of attribute strings.



5
6
7
# File 'lib/perforated/rebuilder.rb', line 5

def strings
  @strings
end

Instance Method Details

#concatenatedObject



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