Class: Pwl::Presenter::Yaml

Inherits:
Object
  • Object
show all
Defined in:
lib/pwl/presenter/yaml.rb

Instance Method Summary collapse

Constructor Details

#initialize(locker) ⇒ Yaml

Returns a new instance of Yaml.



6
7
8
# File 'lib/pwl/presenter/yaml.rb', line 6

def initialize(locker)
    @locker = locker
end

Instance Method Details

#to_sObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/pwl/presenter/yaml.rb', line 10

def to_s
  result = {}
  result[:created] = @locker.created.to_s
  result[:last_accessed] = @locker.last_accessed.to_s
  result[:last_modified] = @locker.last_modified.to_s
  result[:entries] = []
  @locker.all.each do |entry|
    result[:entries] << {
      :uuid => entry.uuid,
      :key => entry.name,
      :value => entry.password
    }
  end
  result.to_yaml
end